当前位置:高等教育资讯网  >  中国高校课件下载中心  >  大学文库  >  浏览文档

复旦大学:《计算机原理 Computer System》课程PPT课件_Linking II(• Static linking • Symbols & Symbol Table • Relocation • Executable Object Files • Loading)

资源类别:文库,文档格式:PPT,文档页数:59,文件大小:345.5KB,团购合买
• Static linking • Symbols & Symbol Table • Relocation • Executable Object Files • Loading • Suggested reading
点击下载完整版文档(PPT)

Linking‖l

1 Linking Ⅱ

Outline Static linking Symbols Symbol Table Relocation Executable Object Files Loading Suggested reading: 7.3-7.5, 7.7-7.9

2 Outline • Static linking • Symbols & Symbol Table • Relocation • Executable Object Files • Loading • Suggested reading: 7.3~7.5, 7.7~7.9

main. c swap c 1. /main. c * swap c void swapO 123 extern int bufa: 23456789 nt buf[2]={1,2} 4. int bufpo &buf[o] 5. int "bufp1 Int maino 6 7. void swapO swapo eturn o If temp 10.} 10. 11 bufp1 =&buf[1] 12 remp =*bufo 13 bufo = bufp1 14 bufpl temp Figure 7.1 P541

3 main.c swap.c 1. /*main.c */ 2. void swap() ; 3. 4. int buf[2] = {1, 2}; 5. 6. Int main() 7. { 8. swap() ; 9. return 0 ; 10. } 1. /*swap.c */ 2. extern int buf[]; 3. 4. int *bufp0 = &buf[0] 5. int *bufp1 ; 6. 7. void swap() 8. { 9. int temp ; 10. 11. bufp1 = &buf[1]; 12. temp = *bufp0 ; 13. *bufp0 = *bufp1 ; 14. *bufp1 = temp ; 15. } Figure 7.1 P541

Example P542 unix> gCc -O2 -g -o p main. c swapc cpp [args] main. c/tmp/main.i ccl /tmp/main. i main. c -o2 [args] -o /tmp/main. s as [args] -o /tmp/main. o /tmp/main.s

4 unix> gcc -O2 -g -o p main.c swap.c cpp [args] main.c /tmp/main.i cc1 /tmp/main.i main.c -O2 [args] -o /tmp/main.s as [args] -o /tmp/main.o /tmp/main.s ld -o p [system obj files] /tmp/main.o /tmp/swap.o unix> Example P542

Obiect file Object file Various code and data sections Instructions are in one section Initialized global variables are in one section Uninitialized global variables are in one section

5 Object file • Object file – Various code and data sections – Instructions are in one section – Initialized global variables are in one section – Uninitialized global variables are in one section

ELF object file format ElF header Program header table (required for executables) text section data section bss section symtab rel. txt rel.data debue g line strap Section header table (required for relocatables) Figure 7.3 P544

6 ELF header Program header table (required for executables) .text section .data section .bss section .symtab .rel.txt .rel.data .debug Section header table (required for relocatables) .line .strtab ELF object file format Figure 7.3 P544

7.3 Ob ject Files

7 7.3 Object Files

Obiect files Relocatable object file Contain binary code and data in a form that can be combined with other relocatable ob ject files to create an executable file Executable object file Contains binary code and data in a form that can be copied directly into memory and executed

8 Object files • Relocatable object file – Contain binary code and data in a form that can be combined with other relocatable object files to create an executable file • Executable object file – Contains binary code and data in a form that can be copied directly into memory and executed

Obiect files Shared ob Ject file e A special type of relocatable object file that can be loaded into memory and linked dynamically,at either load time or run time

9 Object files • Shared object file – A special type of relocatable object file that can be loaded into memory and linked dynamically, at either load time or run time

7.2 Static Linking

10 7.2 Static Linking

点击下载完整版文档(PPT)VIP每日下载上限内不扣除下载券和下载次数;
按次数下载不扣除下载券;
24小时内重复下载只扣除一次;
顺序:VIP每日次数-->可用次数-->下载券;
共59页,可试读20页,点击继续阅读 ↓↓
相关文档

关于我们|帮助中心|下载说明|相关软件|意见反馈|联系我们

Copyright © 2008-现在 cucdc.com 高等教育资讯网 版权所有