Guest User

Untitled

a guest
Apr 20th, 2016
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.46 KB | None | 0 0
  1. $ cat test.cc
  2. extern char* malloc(int);
  3.  
  4. char* foo() {
  5. char* x = (char*) malloc(1024);
  6. return x + 10;
  7. }
  8.  
  9. -----------------------------------------
  10. -----------------------------------------
  11. $ g++ -c -fPIC -O2 -o test.o test.cc
  12. $ objdump -d test.o
  13.  
  14. test.o: file format elf64-x86-64
  15.  
  16.  
  17. Disassembly of section .text:
  18.  
  19. 0000000000000000 <_Z3foov>:
  20. 0: 48 83 ec 08 sub $0x8,%rsp
  21. 4: bf 00 04 00 00 mov $0x400,%edi
  22. 9: e8 00 00 00 00 callq e <_Z3foov+0xe>
  23. e: 48 83 c4 08 add $0x8,%rsp
  24. 12: 48 83 c0 0a add $0xa,%rax
  25. 16: c3 retq
  26.  
  27. -----------------------------------------
  28. -----------------------------------------
  29. $ g++ -c -fPIC -O2 -o test.o test.cc -fno-omit-frame-pointer
  30.  
  31. $ objdump -d test.o
  32.  
  33. test.o: file format elf64-x86-64
  34.  
  35.  
  36. Disassembly of section .text:
  37.  
  38. 0000000000000000 <_Z3foov>:
  39. 0: 55 push %rbp
  40. 1: bf 00 04 00 00 mov $0x400,%edi
  41. 6: 48 89 e5 mov %rsp,%rbp
  42. 9: e8 00 00 00 00 callq e <_Z3foov+0xe>
  43. e: 5d pop %rbp
  44. f: 48
  45.  
  46.  
  47. ---------------------------------------
  48. -----------------------------------------
  49.  
  50. $ aarch64-linux-android-g++ -c -fPIC -O2 -o test.o test.cc
  51. $ aarch64-linux-android-objdump -d test.o
  52.  
  53. test.o: file format elf64-littleaarch64
  54.  
  55.  
  56. Disassembly of section .text:
  57.  
  58. 0000000000000000 <_Z3foov>:
  59. 0: a9bf7bfd stp x29, x30, [sp,#-16]!
  60. 4: 52808000 mov w0, #0x400 // #1024
  61. 8: 910003fd mov x29, sp
  62. c: 94000000 bl 0 <_Z6malloci>
  63. 10: 91002800 add x0, x0, #0xa
  64. 14: a8c17bfd ldp x29, x30, [sp],#16
  65. 18: d65f03c0 ret
  66.  
  67.  
  68. -----------------------------------------
  69. -----------------------------------------
  70.  
  71. $ aarch64-linux-android-g++ -c -fPIC -O2 -o test.o test.cc -fomit-frame-pointer
  72. $ aarch64-linux-android-objdump -d test.o
  73.  
  74. test.o: file format elf64-littleaarch64
  75.  
  76.  
  77. Disassembly of section .text:
  78.  
  79. 0000000000000000 <_Z3foov>:
  80. 0: d10043ff sub sp, sp, #0x10
  81. 4: 52808000 mov w0, #0x400 // #1024
  82. 8: f90003fe str x30, [sp]
  83. c: 94000000 bl 0 <_Z6malloci>
  84. 10: f94003fe ldr x30, [sp]
  85. 14: 91002800 add x0, x0, #0xa
  86. 18: 910043ff add sp, sp, #0x10
  87. 1c: d65f03c0 ret
Advertisement
Add Comment
Please, Sign In to add comment