DOC PREVIEW
CMU CS 15213 - Lecture

This preview shows page 1-2-3-27-28-29 out of 29 pages.

Save
View full document
Premium Document
Do you want full access? Go Premium and unlock all 29 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

15 213 Introduction to Computer Systems object files linkers Topics Program Translation and Execution I Linking Sept 29 1998 class11 ppt executing program memory image executable object file memory image on disk source file A simplistic program translation scheme p c Translators p Loader p 2 CS 213 F 98 Problems efficiency small change requires complete recompilation modularity hard to share common functionality e g printf class11 ppt p1 c Translator p2 c libc o Translator libc c relocatable object files Separate compilation Translator p2 o executable object file contains code and data for all functions defined in libc c p1 o Static Linker p Loader 3 CS 213 F 98 Improves modularity and efficiency but still hard to package common functions class11 ppt Translator p1 c p2 o Translator p2 c static library of relocatable object files executable object file only contains code and data for libc functions that are called from p1 c and p2 c libc a Static libraries p1 o Static Linker p Loader 4 CS 213 F 98 Further improves modularity and efficiency but duplicates common functions in different processes class11 ppt p1 c Translator p2 c CS 213 F 98 libc functions called by p1 c and p2 c are loaded at runtime and shared among processes shared library of dynamically relocatable object files Shared libraries Translator p2 o libc so 5 Loader Dynamic Linker p Static Linker p1 o class11 ppt class11 ppt Translator p1 c p2 o Translator p2 c libc so CS 213 F 98 libm so libwhatever a The complete picture p1 o Static Linker p Loader Dynamic Linker running program 6 C Program char c 100 double d int n 20 i 5 c i z main int i 7 Headers Relocation info Symbol table 0 CS 213 F 98 text sections read only code and data data sections initialized static variables bss sections uninitialized static variables Block Started by Symbol Better Save Space Object file Object files Note local variables don t go in object files They are created at runtime on the stack class11 ppt Increasing addresses main zip main c int p x extern int x zip c int x 0xfe code c Example C program code int p srand p CS 213 F 98 8 zip code p class11 ppt Compiling and linking the example program cc v c main c cfe main c tmp ctmfaacgja ugen O1 tmp ctmfaacgja o tmp ctmcaacgja as1 O1 t m p ctmcaacgja o main o cc c zip c cc c code c 9 C runtime system CS 213 F 98 cc v Wl O0 o main main o zip o code o ld o main O0 call shared usr lib cmplrs cc crt0 o main o zip o code o lc Unix linker class11 ppt 0 0 0 0 Linker functions crt main p zip x code 10 0 CS 213 F 98 crt main zip code x p main 1 Resolving external references 2 Relocating symbol definitions and references crt0 o main o zip o code o class11 ppt Data Text Symbols main c extern int x zip c int x 0xfe code c Lexical entities that correspond to functions and global variables Each symbol has a value address Code consists of symbol definitions and references References can be either local or external main zip int p x CS 213 F 98 Ref to external symbol srand defined in libc so Def of local symbol x Ref to external symbol x 11 Ref to local symbol p Def of local symbol zip zip code p code int p srand p Ref to external symbol zip Def of local symbol p class11 ppt 0 12 CS 213 F 98 type and value of relevant symbols Symbol table which instructions and data items will need to be relocated Section relocation info program code and data Section data for each section in Section data address size number of relocation entries Section headers magic number size and number of sections flags byte ordering executable or relocatable shared calls shared library functions entry point gp value start and sizes of text data and bss segments File and optional headers Alpha ECOFF object files Symbol table Section relocation info Section data Section headers Optional header File header class11 ppt File format bss sbss pdata xdata lit4 lit8 lita rconst rdata sdata data init fini text 13 CS 213 F 98 process init deinit code machine instructions support for exceptions 4 byte literal pool 8 byte literal pool 8 byte literal address pool read only constants read only data small data large data uninitialized data small 4 byte bss Section data relocatable object files Runtime memory image bss segment uninitialized variables block started by symbol better save space data segment initialized variables text segment machine code class11 ppt main zip start 0x00 0 0x50 80 14 sp 16 sp gp 1 t12 gp 32704 gp ra 0 sp t12 32752 gp ra t12 zip gp 1 ra ra 0 sp zero zero v0 gp 32728 gp sp 16 sp zero ra 1 text lita CS 213 F 98 Question Why use gp relative referencing of data and functions resets gp to 32 832 Note ra pc t12 address stored at lita 0 Assembler assumes that gp 32 832 64K 128 2 Note that t12 pc 4 size 0x30 48 0x10 16 text section main o main 0x0 lda 0x4 ldah 0x8 lda 0xc stq 0x10 ldq 0x14 jsr 0x18 ldah 0x1c ldq 0x20 bis 0x24 lda 0x28 lda 0x2c ret class11 ppt text lita 15 Value 0x0 0x0 start 0x00 0 0x50 80 CS 213 F 98 Sclass Symtype Text Proc Undefined Proc size 0x30 48 0x10 16 Symbol table main o main zip Index Name 0 main 1 zip class11 ppt text 0x04 0x10 0x14 0x14 0x18 1 4 13 3 1 12 text lita start 0x00 0 0x50 80 CS 213 F 98 REFQUAD 64 bit reference to the symbol s virtual address HINT 14 bit jsr hint reference LITUSE identifies instance of a literal address previously loaded into a register LITERAL gp relative reference to literal in lita GPDISP instruction pair that sets gp value size 0x30 48 0x10 16 Relocation entries main o main zip Extern Name local local lita local R LU JSR extern zip local 16 REFQUAD extern zip GPDISP LITERAL LITUSE HINT GPDISP Vaddr Symndx Type lita 0x50 class11 ppt main lda ldah lda stq ldq jsr ldah ldq bis lda lda ret main zip 0x0 0x4 0x8 0xc 0x10 0x14 0x18 0x1c 0x20 0x24 0x28 0x2c start 0x00 0 0x50 80 17 CS 213 F 98 Notes 1 LITUSE at 0x14 allows jsr to be replaced by bsr Vaddr Symndx Type Extern Name text 0x04 4 GPDISP local 0x10 13 LITERAL local lita 0x14 3 LITUSE local R LU JSR 0x14 1 HINT extern zip 0x18 12 GPDISP local lita 0x50 1 REFQUAD extern zip size 0x30 48 0x10 16 Relocations main o text lita sp 16 sp gp 1 t12 gp 32704 gp ra 0 sp t12 32752 gp ra t12 zip gp 1 ra ra 0 sp zero zero v0 gp 32728 gp …


View Full Document

CMU CS 15213 - Lecture

Documents in this Course
lecture

lecture

14 pages

lecture

lecture

46 pages

Caches

Caches

9 pages

lecture

lecture

39 pages

Lecture

Lecture

36 pages

Lecture

Lecture

45 pages

Lecture

Lecture

56 pages

lecture

lecture

11 pages

lecture

lecture

9 pages

Lecture

Lecture

36 pages

Lecture

Lecture

37 pages

Exam

Exam

16 pages

Lecture

Lecture

10 pages

Lecture

Lecture

43 pages

Lecture

Lecture

8 pages

Lecture

Lecture

8 pages

Lecture

Lecture

36 pages

Lecture

Lecture

43 pages

Lecture

Lecture

12 pages

Lecture

Lecture

37 pages

Lecture

Lecture

6 pages

Lecture

Lecture

40 pages

coding

coding

2 pages

Exam

Exam

17 pages

Exam

Exam

14 pages

Lecture

Lecture

29 pages

Lecture

Lecture

34 pages

Exam

Exam

11 pages

Lecture

Lecture

9 pages

Lecture

Lecture

37 pages

Lecture

Lecture

36 pages

lecture

lecture

46 pages

Lecture

Lecture

33 pages

Lecture

Lecture

57 pages

Lecture

Lecture

32 pages

Lecture

Lecture

46 pages

Lecture

Lecture

40 pages

Lecture

Lecture

11 pages

Lecture

Lecture

6 pages

Lecture

Lecture

43 pages

Lecture

Lecture

12 pages

Lecture

Lecture

18 pages

Exam

Exam

10 pages

Lecture

Lecture

45 pages

Lecture

Lecture

37 pages

Exam

Exam

24 pages

class09

class09

21 pages

class22

class22

37 pages

class20

class20

30 pages

class27

class27

33 pages

class25

class25

21 pages

class04

class04

31 pages

Lecture

Lecture

59 pages

class01a

class01a

14 pages

class12

class12

45 pages

class29

class29

33 pages

Lecture

Lecture

39 pages

Lecture

Lecture

6 pages

class03

class03

34 pages

lecture

lecture

42 pages

Lecture

Lecture

40 pages

Lecture

Lecture

47 pages

Exam

Exam

19 pages

R06-B

R06-B

25 pages

class17

class17

37 pages

class25

class25

31 pages

Lecture

Lecture

15 pages

final-f06

final-f06

17 pages

Lecture

Lecture

9 pages

lecture

lecture

9 pages

Exam

Exam

15 pages

Lecture

Lecture

22 pages

class11

class11

45 pages

lecture

lecture

50 pages

Linking

Linking

37 pages

Lecture

Lecture

64 pages

Integers

Integers

40 pages

Exam

Exam

11 pages

Lecture

Lecture

37 pages

Lecture

Lecture

44 pages

Lecture

Lecture

37 pages

Lecture

Lecture

9 pages

Lecture

Lecture

37 pages

Lecture

Lecture

45 pages

Final

Final

25 pages

lecture

lecture

9 pages

Lecture

Lecture

30 pages

Lecture

Lecture

16 pages

Final

Final

17 pages

Lecture

Lecture

8 pages

Exam

Exam

11 pages

Lecture

Lecture

47 pages

Lecture

Lecture

9 pages

lecture

lecture

39 pages

Exam

Exam

11 pages

lecture

lecture

41 pages

lecture

lecture

37 pages

Lecture

Lecture

59 pages

Lecture

Lecture

45 pages

Exam 1

Exam 1

18 pages

Lecture

Lecture

41 pages

Lecture

Lecture

32 pages

Lecture

Lecture

30 pages

Lecture

Lecture

9 pages

Lecture

Lecture

9 pages

Lecture

Lecture

15 pages

Lecture

Lecture

11 pages

Lecture

Lecture

9 pages

Lecture

Lecture

34 pages

Lecture

Lecture

40 pages

Lecture

Lecture

4 pages

Lecture

Lecture

46 pages

Lecture

Lecture

8 pages

Lecture

Lecture

65 pages

Lecture

Lecture

38 pages

Lecture

Lecture

35 pages

Lecture

Lecture

8 pages

Lecture

Lecture

34 pages

Lecture

Lecture

8 pages

Exam

Exam

13 pages

Lecture

Lecture

43 pages

Lecture

Lecture

9 pages

Lecture

Lecture

12 pages

Lecture

Lecture

9 pages

Lecture

Lecture

34 pages

Lecture

Lecture

43 pages

Lecture

Lecture

7 pages

Lecture

Lecture

45 pages

Lecture

Lecture

24 pages

Lecture

Lecture

47 pages

Lecture

Lecture

12 pages

Lecture

Lecture

20 pages

Lecture

Lecture

9 pages

Exam

Exam

11 pages

Lecture

Lecture

52 pages

Lecture

Lecture

20 pages

Exam

Exam

11 pages

Lecture

Lecture

35 pages

Lecture

Lecture

47 pages

Lecture

Lecture

18 pages

Lecture

Lecture

30 pages

Lecture

Lecture

59 pages

Lecture

Lecture

37 pages

Lecture

Lecture

22 pages

Lecture

Lecture

35 pages

Exam

Exam

23 pages

Lecture

Lecture

9 pages

Lecture

Lecture

22 pages

class12

class12

32 pages

Lecture

Lecture

8 pages

Lecture

Lecture

39 pages

Lecture

Lecture

44 pages

Lecture

Lecture

38 pages

Lecture

Lecture

69 pages

Lecture

Lecture

41 pages

Lecture

Lecture

12 pages

Lecture

Lecture

52 pages

Lecture

Lecture

59 pages

Lecture

Lecture

39 pages

Lecture

Lecture

83 pages

Lecture

Lecture

59 pages

class01b

class01b

17 pages

Exam

Exam

21 pages

class07

class07

47 pages

Lecture

Lecture

11 pages

Odyssey

Odyssey

18 pages

multicore

multicore

66 pages

Lecture

Lecture

6 pages

lecture

lecture

41 pages

lecture

lecture

55 pages

lecture

lecture

52 pages

lecture

lecture

33 pages

lecture

lecture

46 pages

lecture

lecture

55 pages

lecture

lecture

17 pages

lecture

lecture

49 pages

Exam

Exam

17 pages

lecture

lecture

56 pages

Exam 2

Exam 2

16 pages

Exam 2

Exam 2

16 pages

Notes

Notes

37 pages

Lecture

Lecture

40 pages

Lecture

Lecture

36 pages

Lecture

Lecture

43 pages

Lecture

Lecture

25 pages

Exam

Exam

13 pages

Lecture

Lecture

32 pages

Lecture

Lecture

12 pages

Lecture

Lecture

58 pages

Lecture

Lecture

29 pages

Lecture

Lecture

59 pages

Lecture

Lecture

41 pages

Lecture

Lecture

50 pages

Exam

Exam

17 pages

Lecture

Lecture

29 pages

Lecture

Lecture

44 pages

Lecture

Lecture

41 pages

Lecture

Lecture

52 pages

Lecture

Lecture

40 pages

Lecture

Lecture

33 pages

lecture

lecture

10 pages

Lecture

Lecture

27 pages

Lecture

Lecture

39 pages

Lecture

Lecture

9 pages

Lecture

Lecture

29 pages

Lecture

Lecture

8 pages

Lecture

Lecture

43 pages

Lecture

Lecture

43 pages

Lecture

Lecture

75 pages

Lecture

Lecture

55 pages

Exam

Exam

12 pages

Lecture

Lecture

43 pages

Lecture

Lecture

35 pages

lecture

lecture

36 pages

Exam

Exam

33 pages

lecture

lecture

56 pages

lecture

lecture

64 pages

lecture

lecture

8 pages

Exam

Exam

14 pages

Lecture

Lecture

43 pages

Lecture

Lecture

36 pages

lecture

lecture

56 pages

lecture

lecture

75 pages

lecture

lecture

36 pages

Lecture

Lecture

50 pages

Lecture

Lecture

45 pages

Lecture

Lecture

13 pages

Exam

Exam

23 pages

Lecture

Lecture

10 pages

Lecture

Lecture

48 pages

Lecture

Lecture

83 pages

lecture

lecture

57 pages

Lecture

Lecture

33 pages

Lecture

Lecture

39 pages

Lecture

Lecture

33 pages

lecture

lecture

54 pages

Lecture

Lecture

30 pages

Exam

Exam

13 pages

Lecture

Lecture

36 pages

Lecture

Lecture

40 pages

Exam

Exam

17 pages

Lecture

Lecture

9 pages

Exam

Exam

15 pages

Lecture

Lecture

44 pages

Lecture

Lecture

34 pages

Lecture

Lecture

24 pages

Lecture

Lecture

29 pages

class12

class12

43 pages

lecture

lecture

43 pages

class22

class22

22 pages

R06-B

R06-B

25 pages

class01b

class01b

19 pages

lecture

lecture

29 pages

lab1

lab1

8 pages

Caches

Caches

36 pages

lecture

lecture

55 pages

Lecture,

Lecture,

37 pages

Integers

Integers

40 pages

Linking

Linking

38 pages

lecture

lecture

45 pages

Lecture

Lecture

61 pages

Linking

Linking

33 pages

lecture

lecture

40 pages

lecture

lecture

40 pages

Lecture

Lecture

32 pages

lecture

lecture

48 pages

lecture

lecture

44 pages

Exam

Exam

11 pages

Lecture

Lecture

31 pages

Lecture

Lecture

46 pages

Lecture

Lecture

40 pages

Lecture

Lecture

40 pages

Exam

Exam

12 pages

Lecture

Lecture

42 pages

Lecture

Lecture

36 pages

Lecture

Lecture

45 pages

Lecture

Lecture

41 pages

Lecture

Lecture

13 pages

Lecture

Lecture

35 pages

Lecture

Lecture

20 pages

Final

Final

19 pages

Lecture

Lecture

33 pages

Lecture

Lecture

50 pages

Lecture

Lecture

33 pages

Lecture

Lecture

27 pages

Lecture

Lecture

6 pages

Exam

Exam

15 pages

Lecture

Lecture

24 pages

Lecture

Lecture

23 pages

Lecture

Lecture

43 pages

Lecture

Lecture

32 pages

Lecture

Lecture

52 pages

Lecture

Lecture

37 pages

Lecture

Lecture

36 pages

Lecture

Lecture

34 pages

Lecture

Lecture

40 pages

Lecture

Lecture

15 pages

lecture

lecture

21 pages

Lecture

Lecture

58 pages

Lecture

Lecture

49 pages

Lecture

Lecture

36 pages

Lecture

Lecture

11 pages

Lecture

Lecture

12 pages

Lecture

Lecture

58 pages

Lecture

Lecture

33 pages

Exam

Exam

15 pages

Lecture

Lecture

35 pages

Lecture

Lecture

10 pages

Lecture

Lecture

25 pages

Lecture

Lecture

31 pages

Lecture

Lecture

24 pages

Lecture

Lecture

34 pages

Lecture

Lecture

50 pages

lecture

lecture

35 pages

Lecture

Lecture

11 pages

Lecture

Lecture

39 pages

Lecture

Lecture

45 pages

Lecture

Lecture

41 pages

exam1-f05

exam1-f05

11 pages

Lecture

Lecture

4 pages

Lecture

Lecture

17 pages

Exam

Exam

17 pages

malloc()

malloc()

12 pages

Lecture

Lecture

57 pages

Lecture

Lecture

30 pages

Lecture

Lecture

30 pages

Lecture

Lecture

47 pages

Lecture

Lecture

33 pages

Exam

Exam

12 pages

Lecture

Lecture

43 pages

Lectures

Lectures

33 pages

Lecture

Lecture

36 pages

lecture

lecture

33 pages

Exam

Exam

14 pages

Lecture

Lecture

43 pages

Lecture

Lecture

25 pages

Load more
Download Lecture
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Lecture and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Lecture and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?