?? a.out.h
字號:
#ifndef _A_OUT_H#define _A_OUT_H#define __GNU_EXEC_MACROS__// 執行文件結構。// =============================// unsigned long a_magic // 執行文件魔數。使用N_MAGIC 等宏訪問。// unsigned a_text // 代碼長度,字節數。// unsigned a_data // 數據長度,字節數。// unsigned a_bss // 文件中的未初始化數據區長度,字節數。// unsigned a_syms // 文件中的符號表長度,字節數。// unsigned a_entry // 執行開始地址。// unsigned a_trsize // 代碼重定位信息長度,字節數。// unsigned a_drsize // 數據重定位信息長度,字節數。// -----------------------------struct exec{ unsigned long a_magic; /* 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 */};// 用于取執行結構中的魔數。#ifndef N_MAGIC#define N_MAGIC(exec) ((exec).a_magic)#endif#ifndef OMAGIC/* 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#endif /* not OMAGIC */// 如果魔數不能被識別,則返回真。#ifndef N_BADMAG#define N_BADMAG(x) \(N_MAGIC(x) != OMAGIC && N_MAGIC(x) != NMAGIC \&& N_MAGIC(x) != ZMAGIC)#endif#define _N_BADMAG(x) \(N_MAGIC(x) != OMAGIC && N_MAGIC(x) != NMAGIC \&& N_MAGIC(x) != ZMAGIC)// 程序頭在內存中的偏移位置。#define _N_HDROFF(x) (SEGMENT_SIZE - sizeof (struct exec))// 代碼起始偏移值。#ifndef N_TXTOFF#define N_TXTOFF(x) \(N_MAGIC(x) == ZMAGIC ? _N_HDROFF((x)) + sizeof (struct exec) : sizeof (struct exec))#endif// 數據起始偏移值。#ifndef N_DATOFF#define N_DATOFF(x) (N_TXTOFF(x) + (x).a_text)#endif// 代碼重定位信息偏移值。#ifndef N_TRELOFF#define N_TRELOFF(x) (N_DATOFF(x) + (x).a_data)#endif// 數據重定位信息偏移值。#ifndef N_DRELOFF#define N_DRELOFF(x) (N_TRELOFF(x) + (x).a_trsize)#endif// 符號表偏移值。#ifndef N_SYMOFF#define N_SYMOFF(x) (N_DRELOFF(x) + (x).a_drsize)#endif// 字符串信息偏移值。#ifndef N_STROFF#define N_STROFF(x) (N_SYMOFF(x) + (x).a_syms)#endif/* Address of text segment in memory after it is loaded. *//* 代碼段加載到內存中后的地址 */#ifndef N_TXTADDR#define N_TXTADDR(x) 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. *//* 數據段加載到內存中后的地址。注意,對于下面沒有列出名稱的機器,需要你自己來定義對應的SEGMENT_SIZE */#if defined(vax) || defined(hp300) || defined(pyr)#define SEGMENT_SIZE PAGE_SIZE#endif#ifdef hp300#define PAGE_SIZE 4096#endif#ifdef sony#define SEGMENT_SIZE 0x2000#endif /* Sony. */#ifdef is68k#define SEGMENT_SIZE 0x20000#endif#if defined(m68k) && defined(PORTAR)#define PAGE_SIZE 0x400#define SEGMENT_SIZE PAGE_SIZE#endif#define PAGE_SIZE 4096#define SEGMENT_SIZE 1024// 以段為界的大小。#define _N_SEGMENT_ROUND(x) (((x) + SEGMENT_SIZE - 1) & ~(SEGMENT_SIZE - 1))// 代碼段尾地址。#define _N_TXTENDADDR(x) (N_TXTADDR(x)+(x).a_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 段加載到內存以后的地址 */#ifndef N_BSSADDR#define N_BSSADDR(x) (N_DATADDR(x) + (x).a_data)#endif// nlist 結構。#ifndef N_NLIST_DECLAREDstruct nlist{ union { char *n_name; struct nlist *n_next; long n_strx; } n_un; unsigned char n_type; char n_other; short n_desc; unsigned long n_value;};#endif// 下面定義exec 結構中的變量偏移值。#ifndef N_UNDF#define N_UNDF 0#endif#ifndef N_ABS#define N_ABS 2#endif#ifndef N_TEXT#define N_TEXT 4#endif#ifndef N_DATA#define N_DATA 6#endif#ifndef N_BSS#define N_BSS 8#endif#ifndef N_COMM#define N_COMM 18#endif#ifndef N_FN#define N_FN 15#endif#ifndef N_EXT#define N_EXT 1#endif#ifndef N_TYPE#define N_TYPE 036#endif#ifndef 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. *//* 下面的符號與集合元素有關。所有具有相同名稱N_SET[ATDB]的符號形成一個集合。在代碼部分中已為集合分配了空間,并且每個集合元素的值存放在一個字(word)的空間。空間的第一個字存有集合的長度(集合元素數目)。集合的地址被放入一個N_SETV 符號,它的名稱與集合同名。在滿足未定義的外部引用方面,該符號的行為象一個N_DATA 全局符號。*//* These appear as input to LD, in a .o file. *//* 以下這些符號在目標文件中是作為鏈接程序LD 的輸入。*/#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 *//* Bss 集合元素符號 *//* This is output from LD. *//* 下面是LD 的輸出。*/#define N_SETV 0x1C /* Pointer to set vector in data area. *//* 指向數據區中集合向量。*/#ifndef 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. *//* 下面的結構描述執行一個重定位的操作。文件的代碼重定位部分是這些結構的一個向量,所有這些適用于代碼部分。類似地,數據重定位部分適用于數據部分。*/// 重定位信息結構。struct relocation_info{/* Address (within segment) to be relocated. *//* 需要重定位的地址(在段內)。*/ int r_address;/* The meaning of r_symbolnum depends on r_extern. *//* r_symbolnum 的含義與r_extern 有關。*/ unsigned int r_symbolnum:24;/* 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. *//* 非零意味著值是一個pc 相關的偏移值,因而需要被重定位到自己的地址處以及符號或節指定的改變。 */ 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. *//* 需要被重定位的字段長度(是2 的次方)。因此,若值是2 則表示1<<2 字節數。*/ 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). *//* 1 => 以符號的值重定位。r_symbolnum 是文件符號表中符號的索引。0 => 以段的地址進行重定位。r_symbolnum 是N_TEXT、N_DATA、N_BSS 或N_ABS(N_EXT 比特位也可以被設置,但是毫無意義)。*/ unsigned int r_extern:1;/* Four bits that aren't used, but when writing an object fileit is desirable to clear them. *//* 沒有使用的4 個比特位,但是當進行寫一個目標文件時最好將它們復位掉。*/ unsigned int r_pad:4;};#endif /* no N_RELOCATION_INFO_DECLARED. */#endif /* __A_OUT_GNU_H__ */
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -