strcmp.hex2 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. ## ELF Header
  2. 7f 45 4c 46 ## e_ident[EI_MAG0-3] ELF's magic number
  3. 02 ## e_ident[EI_CLASS] Indicating 64 bit
  4. 01 ## e_ident[EI_DATA] Indicating little endianness
  5. 01 ## e_ident[EI_VERSION] Indicating original elf
  6. 00 ## e_ident[EI_OSABI] Set at 0 because none cares
  7. 00 ## e_ident[EI_ABIVERSION] See above
  8. 00 00 00 00 00 00 00
  9. 02 00 ## e_type Indicating Executable
  10. 3e 00 ## e_machine Indicating AMD64
  11. 01 00 00 00 ## e_version Indicating original elf
  12. b0 00 40 00 00 00 00 00 ## e_entry Address of the entry point
  13. 40 00 00 00 00 00 00 00 ## e_phoff Address of program header table
  14. 00 00 00 00 00 00 00 00 ## e_shoff Address of section header table
  15. 00 00 00 00 ## e_flags
  16. 40 00 ## e_ehsize Indicating our 64 Byte header
  17. 38 00 ## e_phentsize size of a program header table
  18. 02 00 ## e_phnum number of entries in program table
  19. 40 00 ## e_shentsize size of a section header table
  20. 00 00 ## e_shnum number of entries in section table
  21. 00 00 ## e_shstrndx index of the section names
  22. ## Program Header table
  23. 01 00 00 00 ## p_type
  24. 05 00 00 00 ## Flags
  25. 00 00 00 00 00 00 00 00 ## p_offset
  26. 00 00 40 00 00 00 00 00 ## p_vaddr
  27. 00 00 40 00 00 00 00 00 ## Undefined
  28. 11 01 00 00 00 00 00 00 ## p_filesz
  29. 11 01 00 00 00 00 00 00 ## p_memsz
  30. 00 00 20 00 00 00 00 00 ## Required alignment
  31. ## BSS section header
  32. 01 00 00 00 ## p_type
  33. 06 00 00 00 ## Flags
  34. 14 01 00 00 00 00 00 00 ## p_offset
  35. 14 01 60 00 00 00 00 00 ## p_vaddr
  36. 14 01 60 00 00 00 00 00 ## Undefined
  37. 00 00 00 00 00 00 00 00 ## p_filesz
  38. 00 00 40 00 00 00 00 00 ## p_memsz (4MB)
  39. 00 00 20 00 00 00 00 00 ## Required alignment
  40. :_start
  41. c6 04 25 e4 01 60 00 # movb $0x54,0x6001e4
  42. 54
  43. c6 04 25 e5 01 60 00 # movb $0x65,0x6001e5
  44. 65
  45. c6 04 25 e6 01 60 00 # movb $0x73,0x6001e6
  46. 73
  47. c6 04 25 e7 01 60 00 # movb $0x74,0x6001e7
  48. 74
  49. c6 04 25 e8 01 60 00 # movb $0x53,0x6001e8
  50. 53
  51. c6 04 25 e9 01 60 00 # movb $0x54,0x6001e9
  52. 54
  53. c6 04 25 ea 01 60 00 # movb $0x72,0x6001ea
  54. 72
  55. 48 c7 c0 04 02 60 00 # mov $0x600204,%rax
  56. e8 *getstr # callq 400131 <getstr>
  57. 48 c7 c0 01 00 00 00 # mov $0x1,%rax
  58. 48 c7 c7 01 00 00 00 # mov $0x1,%rdi
  59. 48 c7 c6 04 02 60 00 # mov $0x600204,%rsi
  60. 48 c7 c2 2a 00 00 00 # mov $0x2a,%rdx
  61. 0f 05 # syscall
  62. 48 c7 c1 e4 01 60 00 # mov $0x6001e4,%rcx
  63. 48 c7 c2 04 02 60 00 # mov $0x600204,%rdx
  64. e8 *strcmp # callq 4001ae <strcmp>
  65. 48 89 c7 # mov %rax,%rdi
  66. 48 c7 c0 3c 00 00 00 # mov $0x3c,%rax
  67. 0f 05 # syscall
  68. :getstr
  69. 48 89 c3 # mov %rax,%rbx
  70. :getstr.loop
  71. e8 *getchar # callq 40014b <getchar>
  72. 48 83 f8 ff # cmp $0xffffffffffffffff,%rax
  73. 74 .getstr.done # je 400147 <getstr.done>
  74. 88 03 # mov %al,(%rbx)
  75. 48 83 c3 01 # add $0x1,%rbx
  76. eb .getstr.loop # jmp 400134 <getstr.loop>
  77. :getstr.done
  78. c6 03 00 # movb $0x0,(%rbx)
  79. c3 # retq
  80. :getchar
  81. 48 c7 c0 00 00 00 00 # mov $0x0,%rax
  82. 48 c7 c7 00 00 00 00 # mov $0x0,%rdi
  83. 48 8d 34 25 2e 02 60 # lea 0x60022e,%rsi
  84. 00
  85. 48 c7 c2 01 00 00 00 # mov $0x1,%rdx
  86. 0f 05 # syscall
  87. 48 83 f8 01 # cmp $0x1,%rax
  88. 75 .getchar.getchar_fail # jne 40017f <getchar.getchar_fail>
  89. 48 c7 c0 00 00 00 00 # mov $0x0,%rax
  90. 8a 04 25 2e 02 60 00 # mov 0x60022e,%al
  91. c3 # retq
  92. :getchar.getchar_fail
  93. 48 c7 c0 ff ff ff ff # mov $0xffffffffffffffff,%rax
  94. c3 # retq
  95. :putchar
  96. 88 04 25 2e 02 60 00 # mov %al,0x60022e
  97. 48 c7 c0 01 00 00 00 # mov $0x1,%rax
  98. 48 c7 c7 01 00 00 00 # mov $0x1,%rdi
  99. 48 8d 34 25 2e 02 60 # lea 0x60022e,%rsi
  100. 00
  101. 48 c7 c2 01 00 00 00 # mov $0x1,%rdx
  102. 0f 05 # syscall
  103. c3 # retq
  104. :strcmp
  105. 8a 01 # mov (%rcx),%al
  106. 8a 1a # mov (%rdx),%bl
  107. 3c 00 # cmp $0x0,%al
  108. 74 .strcmp.al.eq # je 4001c7 <strcmp.al.eq>
  109. 80 fb 00 # cmp $0x0,%bl
  110. 74 .strcmp.bl.eq.2 # je 4001dc <strcmp.bl.eq.2>
  111. 38 d8 # cmp %bl,%al
  112. 75 .strcmp.bl.eq.2 # jne 4001dc <strcmp.bl.eq.2>
  113. 48 ff c1 # inc %rcx
  114. 48 ff c2 # inc %rdx
  115. eb .strcmp # jmp 4001ae <strcmp>
  116. :strcmp.al.eq
  117. 80 fb 00 # cmp $0x0,%bl
  118. 74 .strcmp.bl.eq.1 # je 4001d4 <strcmp.bl.eq.1>
  119. 48 c7 c0 01 00 00 00 # mov $0x1,%rax
  120. c3 # retq
  121. :strcmp.bl.eq.1
  122. 48 c7 c0 00 00 00 00 # mov $0x0,%rax
  123. c3 # retq
  124. :strcmp.bl.eq.2
  125. 48 c7 c0 01 00 00 00 # mov $0x1,%rax
  126. c3 # retq