carnegie mellonece600/fall16/recitations/... · 2016. 10. 18. · carnegie mellon 21 relocated...

61
Carnegie Mellon 1

Upload: others

Post on 25-Aug-2020

0 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Carnegie Mellonece600/fall16/recitations/... · 2016. 10. 18. · Carnegie Mellon 21 Relocated .text section 00000000004004d0 : 4004d0: 48 83 ec 08 sub $0x8,%rsp 4004d4:

Carnegie Mellon

1

Page 2: Carnegie Mellonece600/fall16/recitations/... · 2016. 10. 18. · Carnegie Mellon 21 Relocated .text section 00000000004004d0 : 4004d0: 48 83 ec 08 sub $0x8,%rsp 4004d4:

Carnegie Mellon

2

Page 3: Carnegie Mellonece600/fall16/recitations/... · 2016. 10. 18. · Carnegie Mellon 21 Relocated .text section 00000000004004d0 : 4004d0: 48 83 ec 08 sub $0x8,%rsp 4004d4:

Carnegie Mellon

3

int sum(int *a, int n);

int array[2] = {1, 2};

int main(){ int val = sum(array, 2); return val;}

int sum(int *a, int n){ int i, s = 0;

for (i = 0; i < n; i++) { s += a[i]; } return s;}

main.c sum.c

Page 4: Carnegie Mellonece600/fall16/recitations/... · 2016. 10. 18. · Carnegie Mellon 21 Relocated .text section 00000000004004d0 : 4004d0: 48 83 ec 08 sub $0x8,%rsp 4004d4:

Carnegie Mellon

4

▪ linux> gcc -Og -o prog main.c sum.c

▪ linux> ./prog

Linker (ld)

Translators(cpp, cc1, as)

main.c

main.o

Translators(cpp, cc1, as)

sum.c

sum.o

prog

main.c sum.c

Page 5: Carnegie Mellonece600/fall16/recitations/... · 2016. 10. 18. · Carnegie Mellon 21 Relocated .text section 00000000004004d0 : 4004d0: 48 83 ec 08 sub $0x8,%rsp 4004d4:

Carnegie Mellon

5

▪▪

Page 6: Carnegie Mellonece600/fall16/recitations/... · 2016. 10. 18. · Carnegie Mellon 21 Relocated .text section 00000000004004d0 : 4004d0: 48 83 ec 08 sub $0x8,%rsp 4004d4:

Carnegie Mellon

6

▪▪

▪▪

Page 7: Carnegie Mellonece600/fall16/recitations/... · 2016. 10. 18. · Carnegie Mellon 21 Relocated .text section 00000000004004d0 : 4004d0: 48 83 ec 08 sub $0x8,%rsp 4004d4:

Carnegie Mellon

7

▪▪ void swap() {…} /* define symbol swap */▪ swap(); /* reference symbol swap */▪ int *xp = &x; /* define symbol xp, reference x */

▪▪ structs▪

Page 8: Carnegie Mellonece600/fall16/recitations/... · 2016. 10. 18. · Carnegie Mellon 21 Relocated .text section 00000000004004d0 : 4004d0: 48 83 ec 08 sub $0x8,%rsp 4004d4:

Carnegie Mellon

8

▪ .o

Page 9: Carnegie Mellonece600/fall16/recitations/... · 2016. 10. 18. · Carnegie Mellon 21 Relocated .text section 00000000004004d0 : 4004d0: 48 83 ec 08 sub $0x8,%rsp 4004d4:

Carnegie Mellon

9

⬛ .o▪

▪ .o .c

⬛ a.out▪

⬛ .so ▪

Page 10: Carnegie Mellonece600/fall16/recitations/... · 2016. 10. 18. · Carnegie Mellon 21 Relocated .text section 00000000004004d0 : 4004d0: 48 83 ec 08 sub $0x8,%rsp 4004d4:

Carnegie Mellon

10

▪ .o

▪ (a.out

▪ .so

Page 11: Carnegie Mellonece600/fall16/recitations/... · 2016. 10. 18. · Carnegie Mellon 21 Relocated .text section 00000000004004d0 : 4004d0: 48 83 ec 08 sub $0x8,%rsp 4004d4:

Carnegie Mellon

11

⬛▪

⬛▪

⬛▪

⬛▪

⬛▪

.text.rodata

.bss.symtab .rel.txt .rel.data .debug

.data

Page 12: Carnegie Mellonece600/fall16/recitations/... · 2016. 10. 18. · Carnegie Mellon 21 Relocated .text section 00000000004004d0 : 4004d0: 48 83 ec 08 sub $0x8,%rsp 4004d4:

Carnegie Mellon

12

⬛▪▪▪

⬛▪▪

⬛▪▪

⬛▪

⬛▪

.text.rodata

.bss.symtab .rel.txt .rel.data .debug

.data

Page 13: Carnegie Mellonece600/fall16/recitations/... · 2016. 10. 18. · Carnegie Mellon 21 Relocated .text section 00000000004004d0 : 4004d0: 48 83 ec 08 sub $0x8,%rsp 4004d4:

Carnegie Mellon

13

⬛▪▪

⬛▪

⬛▪▪▪

Page 14: Carnegie Mellonece600/fall16/recitations/... · 2016. 10. 18. · Carnegie Mellon 21 Relocated .text section 00000000004004d0 : 4004d0: 48 83 ec 08 sub $0x8,%rsp 4004d4:

Carnegie Mellon

14

int sum(int *a, int n);

int array[2] = {1, 2};

int main(){ int val = sum(array, 2); return val;}

main.c

int sum(int *a, int n){ int i, s = 0;

for (i = 0; i < n; i++) { s += a[i]; } return s;}

sum.c

val…

…i s

Page 15: Carnegie Mellonece600/fall16/recitations/... · 2016. 10. 18. · Carnegie Mellon 21 Relocated .text section 00000000004004d0 : 4004d0: 48 83 ec 08 sub $0x8,%rsp 4004d4:

Carnegie Mellon

15

▪▪

int foo=5;

p1() {}

int foo;

p2() {}

p1.c p2.c

Page 16: Carnegie Mellonece600/fall16/recitations/... · 2016. 10. 18. · Carnegie Mellon 21 Relocated .text section 00000000004004d0 : 4004d0: 48 83 ec 08 sub $0x8,%rsp 4004d4:

Carnegie Mellon

16

⬛▪▪

⬛▪

Page 17: Carnegie Mellonece600/fall16/recitations/... · 2016. 10. 18. · Carnegie Mellon 21 Relocated .text section 00000000004004d0 : 4004d0: 48 83 ec 08 sub $0x8,%rsp 4004d4:

Carnegie Mellon

17

int x;p1() {}

int x;p2() {}

int x;int y;p1() {}

double x;p2() {}

int x=7;int y=5;p1() {}

double x;p2() {}

int x=7;p1() {}

int x;p2() {}

int x;p1() {} p1() {} p1

x

x p2 y

x p2 y

x

Page 18: Carnegie Mellonece600/fall16/recitations/... · 2016. 10. 18. · Carnegie Mellon 21 Relocated .text section 00000000004004d0 : 4004d0: 48 83 ec 08 sub $0x8,%rsp 4004d4:

Carnegie Mellon

18

▪ static

▪▪ extern

Page 19: Carnegie Mellonece600/fall16/recitations/... · 2016. 10. 18. · Carnegie Mellon 21 Relocated .text section 00000000004004d0 : 4004d0: 48 83 ec 08 sub $0x8,%rsp 4004d4:

Carnegie Mellon

19

main()

main.o

sum()

sum.o

int array[2]={1,2}

.text

.data

.text

.data

.text

main()

sum().text

.symtab.debug

.dataint array[2]={1,2}

Page 20: Carnegie Mellonece600/fall16/recitations/... · 2016. 10. 18. · Carnegie Mellon 21 Relocated .text section 00000000004004d0 : 4004d0: 48 83 ec 08 sub $0x8,%rsp 4004d4:

Carnegie Mellon

20objdump –r –d main.o

0000000000000000 <main>: 0: 48 83 ec 08 sub $0x8,%rsp 4: be 02 00 00 00 mov $0x2,%esi 9: bf 00 00 00 00 mov $0x0,%edi # %edi = &array a: R_X86_64_32 array # Relocation entry

e: e8 00 00 00 00 callq 13 <main+0x13> # sum() f: R_X86_64_PC32 sum-0x4 # Relocation entry 13: 48 83 c4 08 add $0x8,%rsp 17: c3 retq

main.o

int array[2] = {1, 2};

int main(){ int val = sum(array, 2); return val;}

main.c

Page 21: Carnegie Mellonece600/fall16/recitations/... · 2016. 10. 18. · Carnegie Mellon 21 Relocated .text section 00000000004004d0 : 4004d0: 48 83 ec 08 sub $0x8,%rsp 4004d4:

Carnegie Mellon

21

Relocated .text section00000000004004d0 <main>: 4004d0: 48 83 ec 08 sub $0x8,%rsp 4004d4: be 02 00 00 00 mov $0x2,%esi 4004d9: bf 18 10 60 00 mov $0x601018,%edi # %edi = &array 4004de: e8 05 00 00 00 callq 4004e8 <sum> # sum() 4004e3: 48 83 c4 08 add $0x8,%rsp 4004e7: c3 retq

00000000004004e8 <sum>: 4004e8: b8 00 00 00 00 mov $0x0,%eax 4004ed: ba 00 00 00 00 mov $0x0,%edx 4004f2: eb 09 jmp 4004fd <sum+0x15> 4004f4: 48 63 ca movslq %edx,%rcx 4004f7: 03 04 8f add (%rdi,%rcx,4),%eax 4004fa: 83 c2 01 add $0x1,%edx 4004fd: 39 f2 cmp %esi,%edx 4004ff: 7c f3 jl 4004f4 <sum+0xc> 400501: f3 c3 repz retq

Source: objdump -dx prog

Page 22: Carnegie Mellonece600/fall16/recitations/... · 2016. 10. 18. · Carnegie Mellon 21 Relocated .text section 00000000004004d0 : 4004d0: 48 83 ec 08 sub $0x8,%rsp 4004d4:

Carnegie Mellon

22

malloc

%rsp

brk

0x400000

data bss

.init text .rodata

Page 23: Carnegie Mellonece600/fall16/recitations/... · 2016. 10. 18. · Carnegie Mellon 21 Relocated .text section 00000000004004d0 : 4004d0: 48 83 ec 08 sub $0x8,%rsp 4004d4:

Carnegie Mellon

23

▪▪

▪▪

Page 24: Carnegie Mellonece600/fall16/recitations/... · 2016. 10. 18. · Carnegie Mellon 21 Relocated .text section 00000000004004d0 : 4004d0: 48 83 ec 08 sub $0x8,%rsp 4004d4:

Carnegie Mellon

24

⬛ a▪

Page 25: Carnegie Mellonece600/fall16/recitations/... · 2016. 10. 18. · Carnegie Mellon 21 Relocated .text section 00000000004004d0 : 4004d0: 48 83 ec 08 sub $0x8,%rsp 4004d4:

Carnegie Mellon

25

atoi.c

atoi.o

printf.c

printf.o

libc.a

random.c

random.o

unix> ar rs libc.a \ atoi.o printf.o … random.o

Page 26: Carnegie Mellonece600/fall16/recitations/... · 2016. 10. 18. · Carnegie Mellon 21 Relocated .text section 00000000004004d0 : 4004d0: 48 83 ec 08 sub $0x8,%rsp 4004d4:

Carnegie Mellon

26

#include <stdio.h>#include "vector.h"

int x[2] = {1, 2};int y[2] = {3, 4};int z[2];

int main(){ addvec(x, y, z, 2); printf("z = [%d %d]\n”, z[0], z[1]); return 0;} main2.c

void addvec(int *x, int *y, int *z, int n) { int i;

for (i = 0; i < n; i++) z[i] = x[i] + y[i];}

void multvec(int *x, int *y, int *z, int n){ int i;

for (i = 0; i < n; i++) z[i] = x[i] * y[i];} multvec.c

addvec.c

Page 27: Carnegie Mellonece600/fall16/recitations/... · 2016. 10. 18. · Carnegie Mellon 21 Relocated .text section 00000000004004d0 : 4004d0: 48 83 ec 08 sub $0x8,%rsp 4004d4:

Carnegie Mellon

27

Translators(cpp, cc1, as)

main2.c

main2.o

libc.a

Linker (ld)

prog2c

printf.o printf.o

libvector.a

addvec.o

vector.h Archiver(ar)

addvec.o multvec.o

Page 28: Carnegie Mellonece600/fall16/recitations/... · 2016. 10. 18. · Carnegie Mellon 21 Relocated .text section 00000000004004d0 : 4004d0: 48 83 ec 08 sub $0x8,%rsp 4004d4:

Carnegie Mellon

28

⬛▪▪▪

⬛▪▪

unix> gcc -L. libtest.o -lmine unix> gcc -L. -lmine libtest.o libtest.o: In function `main': libtest.o(.text+0x4): undefined reference to `libfun'

Page 29: Carnegie Mellonece600/fall16/recitations/... · 2016. 10. 18. · Carnegie Mellon 21 Relocated .text section 00000000004004d0 : 4004d0: 48 83 ec 08 sub $0x8,%rsp 4004d4:

Carnegie Mellon

29

▪▪▪

▪ .so

Page 30: Carnegie Mellonece600/fall16/recitations/... · 2016. 10. 18. · Carnegie Mellon 21 Relocated .text section 00000000004004d0 : 4004d0: 48 83 ec 08 sub $0x8,%rsp 4004d4:

Carnegie Mellon

30

⬛▪▪

▪▪▪▪

⬛▪

Page 31: Carnegie Mellonece600/fall16/recitations/... · 2016. 10. 18. · Carnegie Mellon 21 Relocated .text section 00000000004004d0 : 4004d0: 48 83 ec 08 sub $0x8,%rsp 4004d4:

Carnegie Mellon

31

Translators (cpp, cc1, as)

main2.c

main2.o

libc.solibvector.so

Linker (ld)

prog2l

Dynamic linker (ld-linux.so)

libc.solibvector.so

Partially linked executable object file

Relocatableobject file

Fully linked executablein memory

vector.h

Loader (execve)

unix> gcc -shared -o libvector.so \ addvec.c multvec.c

Page 32: Carnegie Mellonece600/fall16/recitations/... · 2016. 10. 18. · Carnegie Mellon 21 Relocated .text section 00000000004004d0 : 4004d0: 48 83 ec 08 sub $0x8,%rsp 4004d4:

Carnegie Mellon

32

#include <stdio.h>#include <stdlib.h>#include <dlfcn.h>

int x[2] = {1, 2};int y[2] = {3, 4};int z[2];

int main(){ void *handle; void (*addvec)(int *, int *, int *, int); char *error;

/* Dynamically load the shared library that contains addvec() */ handle = dlopen("./libvector.so", RTLD_LAZY); if (!handle) { fprintf(stderr, "%s\n", dlerror()); exit(1); }

/* Get a pointer to the addvec() function we just loaded */ addvec = dlsym(handle, "addvec"); if ((error = dlerror()) != NULL) { fprintf(stderr, "%s\n", error); exit(1); }

/* Now we can call addvec() just like any other function */ addvec(x, y, z, 2); printf("z = [%d %d]\n", z[0], z[1]);

/* Unload the shared library */ if (dlclose(handle) < 0) { fprintf(stderr, "%s\n", dlerror()); exit(1); } return 0;}

dll.c

Page 33: Carnegie Mellonece600/fall16/recitations/... · 2016. 10. 18. · Carnegie Mellon 21 Relocated .text section 00000000004004d0 : 4004d0: 48 83 ec 08 sub $0x8,%rsp 4004d4:

Carnegie Mellon

33

▪▪▪

Page 34: Carnegie Mellonece600/fall16/recitations/... · 2016. 10. 18. · Carnegie Mellon 21 Relocated .text section 00000000004004d0 : 4004d0: 48 83 ec 08 sub $0x8,%rsp 4004d4:

Carnegie Mellon

34

Page 35: Carnegie Mellonece600/fall16/recitations/... · 2016. 10. 18. · Carnegie Mellon 21 Relocated .text section 00000000004004d0 : 4004d0: 48 83 ec 08 sub $0x8,%rsp 4004d4:

Carnegie Mellon

35

Page 36: Carnegie Mellonece600/fall16/recitations/... · 2016. 10. 18. · Carnegie Mellon 21 Relocated .text section 00000000004004d0 : 4004d0: 48 83 ec 08 sub $0x8,%rsp 4004d4:

Carnegie Mellon

36

▪▪

Page 37: Carnegie Mellonece600/fall16/recitations/... · 2016. 10. 18. · Carnegie Mellon 21 Relocated .text section 00000000004004d0 : 4004d0: 48 83 ec 08 sub $0x8,%rsp 4004d4:

Carnegie Mellon

37

▪⬛

▪▪

Page 38: Carnegie Mellonece600/fall16/recitations/... · 2016. 10. 18. · Carnegie Mellon 21 Relocated .text section 00000000004004d0 : 4004d0: 48 83 ec 08 sub $0x8,%rsp 4004d4:

Carnegie Mellon

38

▪⬛

▪▪▪

Page 39: Carnegie Mellonece600/fall16/recitations/... · 2016. 10. 18. · Carnegie Mellon 21 Relocated .text section 00000000004004d0 : 4004d0: 48 83 ec 08 sub $0x8,%rsp 4004d4:

Carnegie Mellon

39

▪ −▪▪▪

⬛ − −⬛

▪▪▪

Page 40: Carnegie Mellonece600/fall16/recitations/... · 2016. 10. 18. · Carnegie Mellon 21 Relocated .text section 00000000004004d0 : 4004d0: 48 83 ec 08 sub $0x8,%rsp 4004d4:

Carnegie Mellon

40

▪▪▪

Page 41: Carnegie Mellonece600/fall16/recitations/... · 2016. 10. 18. · Carnegie Mellon 21 Relocated .text section 00000000004004d0 : 4004d0: 48 83 ec 08 sub $0x8,%rsp 4004d4:

Carnegie Mellon

41

Page 42: Carnegie Mellonece600/fall16/recitations/... · 2016. 10. 18. · Carnegie Mellon 21 Relocated .text section 00000000004004d0 : 4004d0: 48 83 ec 08 sub $0x8,%rsp 4004d4:

Carnegie Mellon

42

0 011 00 0 01 0000 010 00 0 00 1000 011 10 0 01 011

Page 43: Carnegie Mellonece600/fall16/recitations/... · 2016. 10. 18. · Carnegie Mellon 21 Relocated .text section 00000000004004d0 : 4004d0: 48 83 ec 08 sub $0x8,%rsp 4004d4:

Carnegie Mellon

43

⬛⬛⬛

▪⬛

▪▪

▪▪

Page 44: Carnegie Mellonece600/fall16/recitations/... · 2016. 10. 18. · Carnegie Mellon 21 Relocated .text section 00000000004004d0 : 4004d0: 48 83 ec 08 sub $0x8,%rsp 4004d4:

Carnegie Mellon

44

00000000004004b6 <mystery>: 4004b6: mov $0x0,%eax 4004bb: jmp 4004d3 <mystery+0x1d> 4004bd: movslq %eax,%rdx 4004c0: lea (%rdi,%rdx,4),%rcx 4004c4: mov (%rcx),%edx 4004c6: test $0x1,%dl 4004c9: jne 4004d0 <mystery+0x1a> 4004cb: add $0x1,%edx 4004ce: mov %edx,(%rcx) 4004d0: add $0x1,%eax 4004d3: cmp %esi,%eax 4004d5: jne 4004bd <mystery+0x7> 4004d7: repz retq

Page 45: Carnegie Mellonece600/fall16/recitations/... · 2016. 10. 18. · Carnegie Mellon 21 Relocated .text section 00000000004004d0 : 4004d0: 48 83 ec 08 sub $0x8,%rsp 4004d4:

Carnegie Mellon

45

00000000004004b6 <mystery>: 4004b6: mov $0x0,%eax 4004bb: jmp 4004d3 <mystery+0x1d> 4004bd: movslq %eax,%rdx 4004c0: lea (%rdi,%rdx,4),%rcx 4004c4: mov (%rcx),%edx 4004c6: test $0x1,%dl 4004c9: jne 4004d0 <mystery+0x1a> 4004cb: add $0x1,%edx 4004ce: mov %edx,(%rcx) 4004d0: add $0x1,%eax 4004d3: cmp %esi,%eax 4004d5: jne 4004bd <mystery+0x7> 4004d7: repz retq

i < n i++

(array[i] & 1)array[i] += 1

i = 0

Page 46: Carnegie Mellonece600/fall16/recitations/... · 2016. 10. 18. · Carnegie Mellon 21 Relocated .text section 00000000004004d0 : 4004d0: 48 83 ec 08 sub $0x8,%rsp 4004d4:

Carnegie Mellon

46

▪▪▪

Page 47: Carnegie Mellonece600/fall16/recitations/... · 2016. 10. 18. · Carnegie Mellon 21 Relocated .text section 00000000004004d0 : 4004d0: 48 83 ec 08 sub $0x8,%rsp 4004d4:

Carnegie Mellon

47

Page 48: Carnegie Mellonece600/fall16/recitations/... · 2016. 10. 18. · Carnegie Mellon 21 Relocated .text section 00000000004004d0 : 4004d0: 48 83 ec 08 sub $0x8,%rsp 4004d4:

Carnegie Mellon

48

J = 3H = 15

Page 49: Carnegie Mellonece600/fall16/recitations/... · 2016. 10. 18. · Carnegie Mellon 21 Relocated .text section 00000000004004d0 : 4004d0: 48 83 ec 08 sub $0x8,%rsp 4004d4:

Carnegie Mellon

49

▪⬛

▪▪▪▪▪

Page 50: Carnegie Mellonece600/fall16/recitations/... · 2016. 10. 18. · Carnegie Mellon 21 Relocated .text section 00000000004004d0 : 4004d0: 48 83 ec 08 sub $0x8,%rsp 4004d4:

Carnegie Mellon

50

⬛▪▪▪

Page 51: Carnegie Mellonece600/fall16/recitations/... · 2016. 10. 18. · Carnegie Mellon 21 Relocated .text section 00000000004004d0 : 4004d0: 48 83 ec 08 sub $0x8,%rsp 4004d4:

Carnegie Mellon

51

⬛▪

▪▪▪

▪▪

▪▪▪▪

▪▪▪▪

▪▪▪

Page 52: Carnegie Mellonece600/fall16/recitations/... · 2016. 10. 18. · Carnegie Mellon 21 Relocated .text section 00000000004004d0 : 4004d0: 48 83 ec 08 sub $0x8,%rsp 4004d4:

Carnegie Mellon

52

● All instructions follow same general pattern● Differ in what gets computed on each step

Page 53: Carnegie Mellonece600/fall16/recitations/... · 2016. 10. 18. · Carnegie Mellon 21 Relocated .text section 00000000004004d0 : 4004d0: 48 83 ec 08 sub $0x8,%rsp 4004d4:

Carnegie Mellon

53

Page 54: Carnegie Mellonece600/fall16/recitations/... · 2016. 10. 18. · Carnegie Mellon 21 Relocated .text section 00000000004004d0 : 4004d0: 48 83 ec 08 sub $0x8,%rsp 4004d4:

Carnegie Mellon

54

⬛I1: add r1, r2

I2: mrmovq d(r2), r3

I3: rmmovq r3, d(r2)

⬛▪▪▪

⬛▪▪

Page 55: Carnegie Mellonece600/fall16/recitations/... · 2016. 10. 18. · Carnegie Mellon 21 Relocated .text section 00000000004004d0 : 4004d0: 48 83 ec 08 sub $0x8,%rsp 4004d4:

Carnegie Mellon

55

⬛I1: add r1, r2

I2: mrmovq d(r2), r3

I3: rmmovq r3, d(r2)

⬛▪▪▪

⬛▪▪

Page 56: Carnegie Mellonece600/fall16/recitations/... · 2016. 10. 18. · Carnegie Mellon 21 Relocated .text section 00000000004004d0 : 4004d0: 48 83 ec 08 sub $0x8,%rsp 4004d4:

Carnegie Mellon

56

⬛I1: add r1, r2

I2: mrmovq d(r2), r3

I3: rmmovq r3, d(r2)

⬛▪▪▪

⬛▪▪

Page 57: Carnegie Mellonece600/fall16/recitations/... · 2016. 10. 18. · Carnegie Mellon 21 Relocated .text section 00000000004004d0 : 4004d0: 48 83 ec 08 sub $0x8,%rsp 4004d4:

Carnegie Mellon

57

⬛I1: add r1, r2

I2: mrmovq d(r2), r3

I3: rmmovq r3, d(r2)

⬛▪▪▪

⬛▪▪▪

Page 58: Carnegie Mellonece600/fall16/recitations/... · 2016. 10. 18. · Carnegie Mellon 21 Relocated .text section 00000000004004d0 : 4004d0: 48 83 ec 08 sub $0x8,%rsp 4004d4:

Carnegie Mellon

58

⬛I1: add r1, r2

I2: mrmovq d(r2), r3

I3: rmmovq r3, d(r2)

⬛▪▪

⬛▪▪

Page 59: Carnegie Mellonece600/fall16/recitations/... · 2016. 10. 18. · Carnegie Mellon 21 Relocated .text section 00000000004004d0 : 4004d0: 48 83 ec 08 sub $0x8,%rsp 4004d4:

Carnegie Mellon

59

⬛I1: add r1, r2

I2: mrmovq d(r2), r3

I3: rmmovq r3, d(r2)

⬛▪▪▪

⬛▪▪▪▪

Page 60: Carnegie Mellonece600/fall16/recitations/... · 2016. 10. 18. · Carnegie Mellon 21 Relocated .text section 00000000004004d0 : 4004d0: 48 83 ec 08 sub $0x8,%rsp 4004d4:

Carnegie Mellon

60

⬛▪▪▪

⬛▪▪▪

⬛▪▪

Page 61: Carnegie Mellonece600/fall16/recitations/... · 2016. 10. 18. · Carnegie Mellon 21 Relocated .text section 00000000004004d0 : 4004d0: 48 83 ec 08 sub $0x8,%rsp 4004d4:

Carnegie Mellon

61