中国高校课件下载中心 》 教学资源 》 大学文库

复旦大学:《计算机原理 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
刷新页面文档预览

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

刷新页面下载完整文档
VIP每日下载上限内不扣除下载券和下载次数;
按次数下载不扣除下载券;
注册用户24小时内重复下载只扣除一次;
顺序:VIP每日次数-->可用次数-->下载券;
相关文档