<!-- /* Font Definitions */ @font-face {font-family:宋体; panose-1:2 1 6 0 3 1 1 1 1 1; mso-font-alt:SimSun; mso-font-charset:134; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:3 135135232 16 0 262145 0;} @font-face {font-family:"Cambria Math"; panose-1:2 4 5 3 5 4 6 3 2 4; mso-font-charset:0; mso-generic-font-family:roman; mso-font-pitch:variable; mso-font-signature:-1610611985 1107304683 0 0 159 0;} @font-face {font-family:Calibri; panose-1:2 15 5 2 2 2 4 3 2 4; mso-font-charset:0; mso-generic-font-family:swiss; mso-font-pitch:variable; mso-font-signature:-1610611985 1073750139 0 0 159 0;} @font-face {font-family:Verdana; panose-1:2 11 6 4 3 5 4 4 2 4; mso-font-charset:0; mso-generic-font-family:swiss; mso-font-pitch:variable; mso-font-signature:536871559 0 0 0 415 0;} @font-face {font-family:"/@宋体"; panose-1:2 1 6 0 3 1 1 1 1 1; mso-font-charset:134; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:3 135135232 16 0 262145 0;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {mso-style-priority:1; mso-style-unhide:no; mso-style-qformat:yes; mso-style-parent:""; margin-top:0cm; margin-right:0cm; margin-bottom:10.0pt; margin-left:0cm; mso-pagination:widow-orphan; font-size:11.0pt; mso-bidi-font-size:10.0pt; font-family:"Calibri","sans-serif"; mso-ascii-font-family:Calibri; mso-ascii-theme-font:minor-latin; mso-fareast-font-family:宋体; mso-fareast-theme-font:minor-fareast; mso-hansi-font-family:Calibri; mso-hansi-theme-font:minor-latin; mso-bidi-font-family:"Times New Roman"; mso-bidi-theme-font:minor-bidi;} span.MsoPlaceholderText {mso-style-noshow:yes; mso-style-priority:99; mso-style-unhide:no; color:gray;} p.Publishwithline, li.Publishwithline, div.Publishwithline {mso-style-name:"Publish with line"; mso-style-noshow:yes; mso-style-unhide:no; mso-style-qformat:yes; mso-style-parent:""; margin:0cm; margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:16.0pt; mso-bidi-font-size:19.0pt; font-family:"Calibri","sans-serif"; mso-ascii-font-family:Calibri; mso-ascii-theme-font:major-latin; mso-fareast-font-family:宋体; mso-fareast-theme-font:major-fareast; mso-hansi-font-family:Calibri; mso-hansi-theme-font:major-latin; mso-bidi-font-family:"Times New Roman"; mso-bidi-theme-font:major-bidi; color:#17365D; mso-themecolor:text2; mso-themeshade:191; font-weight:bold;} p.PadderBetweenControlandBody, li.PadderBetweenControlandBody, div.PadderBetweenControlandBody {mso-style-name:"Padder Between Control and Body"; mso-style-noshow:yes; mso-style-unhide:no; mso-style-next:正文; margin-top:0cm; margin-right:0cm; margin-bottom:6.0pt; margin-left:0cm; mso-pagination:widow-orphan; font-size:1.0pt; font-family:"Calibri","sans-serif"; mso-ascii-font-family:Calibri; mso-ascii-theme-font:minor-latin; mso-fareast-font-family:宋体; mso-fareast-theme-font:minor-fareast; mso-hansi-font-family:Calibri; mso-hansi-theme-font:minor-latin; mso-bidi-font-family:"Times New Roman"; mso-bidi-theme-font:minor-bidi;} p.underline, li.underline, div.underline {mso-style-name:underline; mso-style-noshow:yes; mso-style-unhide:no; mso-style-parent:""; margin-top:2.0pt; margin-right:0cm; margin-bottom:0cm; margin-left:0cm; margin-bottom:.0001pt; mso-pagination:widow-orphan; border:none; mso-border-bottom-alt:solid #4F81BD 1.0pt; mso-border-bottom-themecolor:accent1; padding:0cm; mso-padding-alt:0cm 0cm 2.0pt 0cm; font-size:1.0pt; font-family:"Calibri","sans-serif"; mso-ascii-font-family:Calibri; mso-ascii-theme-font:minor-latin; mso-fareast-font-family:宋体; mso-fareast-theme-font:minor-fareast; mso-hansi-font-family:Calibri; mso-hansi-theme-font:minor-latin; mso-bidi-font-family:"Times New Roman"; mso-bidi-theme-font:minor-bidi;} .MsoChpDefault {mso-style-type:export-only; mso-default-props:yes; font-size:11.0pt; mso-ansi-font-size:11.0pt; mso-bidi-font-size:10.0pt; mso-bidi-font-family:"Times New Roman"; mso-bidi-theme-font:minor-bidi; mso-font-kerning:0pt;} .MsoPapDefault {mso-style-type:export-only; margin-bottom:10.0pt;} /* Page Definitions */ @page {mso-page-border-surround-header:no; mso-page-border-surround-footer:no;} @page Section1 {size:595.3pt 841.9pt; margin:72.0pt 90.0pt 72.0pt 90.0pt; mso-header-margin:36.0pt; mso-footer-margin:36.0pt; mso-paper-source:0;} div.Section1 {page:Section1;} -->
ELF header(ELF 头部)
Program header table( 程序头表)
Segment1 (段1 )
Segment2 (段2 )
………
Sengmentn (段n )
Setion header table( 节头表,可选)// 描述了映射加载关系,可由OBJDUMP 查看objdump -h 我的程序
Unix 系统在可执行文件的加载过程中,除了读取必要的头部信息,并没有任何从磁盘到存储器的数据拷贝,只是简单进行映射,知道 CPU 访问一个被映射的虚拟页产生缺页异常后,才进行拷贝。
地址 | 作用 | 说明 |
>=0xc000 0000 | 内核虚拟存储器 | 系统保留区 |
<0xc000 0000 | Stack (用户栈) | %EBP,%ESP |
| ↓
↑ |
空闲/ 动态库也放在此 |
>=0x4000 0000 | 文件映射区 | 只映射,page fault 后加载 |
<0x4000 0000 |
↑ |
空闲
|
| Heap( 运行时堆) | 通过brk/sbrk 系统调用扩大堆,向上增长(malloc) 。 |
| .data 、.bss( 读写段) | 可执行文件中获取,重定位 |
>=0x0804 8000 | .init 、.text 、.rodata( 只读段) | 可执行文件中获取,重定位 |
<0x0804 8000 | 保留区域 |
|
C 程序的入口点是 _start ,这段启动代码是在目标文件 ctrl.o 中定义的。启动代码中首先调用初始化函数,然后调用 atexit 函数,用于注册在 exit 函数被调用 ( 程序退出 ) 时应该被调用的函数。最后,启动代码调用 main 函数,在 main 函数返回后,调用系统调用 _exit() ,将控制返回给操作系统。