hex0glo.hex2 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  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. e8 *getchar # callq 600133 <getchar>
  42. 48 83 f8 ff # cmp $0xffffffffffffffff,%rax
  43. 74 ._start.done # je 6000cd <_start.done>
  44. 48 83 f8 20 # cmp $0x20,%rax
  45. 74 ._start # je 600078 <_start>
  46. 48 83 f8 09 # cmp $0x9,%rax
  47. 74 ._start # je 600078 <_start>
  48. 48 83 f8 0a # cmp $0xa,%rax
  49. 74 ._start # je 600078 <_start>
  50. 48 83 f8 23 # cmp $0x23,%rax
  51. 74 .skip_comment # je 6000dd <skip_comment>
  52. e8 *hex_digit # callq 6000f0 <hex_digit>
  53. 48 c1 e0 04 # shl $0x4,%rax
  54. 48 89 04 25 a0 01 60 # mov %rax,0x6001a0
  55. 00
  56. e8 *getchar # callq 600133 <getchar>
  57. e8 *hex_digit # callq 6000f0 <hex_digit>
  58. 48 09 04 25 a0 01 60 # or %rax,0x6001a0
  59. 00
  60. 48 8b 04 25 a0 01 60 # mov 0x6001a0,%rax
  61. 00
  62. e8 *putchar # callq 60016f <putchar>
  63. eb ._start # jmp 600078 <_start>
  64. :_start.done
  65. 48 c7 c0 3c 00 00 00 # mov $0x3c,%rax
  66. 48 c7 c7 00 00 00 00 # mov $0x0,%rdi
  67. 0f 05 # syscall
  68. :skip_comment
  69. e8 *getchar # callq 600133 <getchar>
  70. 48 83 f8 ff # cmp $0xffffffffffffffff,%rax
  71. 74 .die # je 600123 <die>
  72. 48 83 f8 0a # cmp $0xa,%rax
  73. 74 ._start # je 600078 <_start>
  74. eb .skip_comment # jmp 6000dd <skip_comment>
  75. :hex_digit
  76. 48 83 f8 30 # cmp $0x30,%rax
  77. 7c .hex_digit.next1 # jl 600101 <hex_digit.next1>
  78. 48 83 f8 39 # cmp $0x39,%rax
  79. 7f .hex_digit.next1 # jg 600101 <hex_digit.next1>
  80. 48 83 e8 30 # sub $0x30,%rax
  81. c3 # retq
  82. :hex_digit.next1
  83. 48 83 f8 61 # cmp $0x61,%rax
  84. 7c .hex_digit.next2 # jl 600112 <hex_digit.next2>
  85. 48 83 f8 66 # cmp $0x66,%rax
  86. 7f .hex_digit.next2 # jg 600112 <hex_digit.next2>
  87. 48 83 e8 57 # sub $0x57,%rax
  88. c3 # retq
  89. :hex_digit.next2
  90. 48 83 f8 41 # cmp $0x41,%rax
  91. 7c .die # jl 600123 <die>
  92. 48 83 f8 46 # cmp $0x46,%rax
  93. 7f .die # jg 600123 <die>
  94. 48 83 e8 37 # sub $0x37,%rax
  95. c3 # retq
  96. :die
  97. 48 c7 c0 3c 00 00 00 # mov $0x3c,%rax
  98. 48 c7 c7 01 00 00 00 # mov $0x1,%rdi
  99. 0f 05 # syscall
  100. :getchar
  101. 48 c7 c0 00 00 00 00 # mov $0x0,%rax
  102. 48 c7 c7 00 00 00 00 # mov $0x0,%rdi
  103. 48 8d 34 25 98 01 60 # lea 0x600198,%rsi
  104. 00
  105. 48 c7 c2 01 00 00 00 # mov $0x1,%rdx
  106. 0f 05 # syscall
  107. 48 83 f8 01 # cmp $0x1,%rax
  108. 75 .getchar.getchar_fail # jne 600167 <getchar.getchar_fail>
  109. 48 c7 c0 00 00 00 00 # mov $0x0,%rax
  110. 8a 04 25 98 01 60 00 # mov 0x600198,%al
  111. c3 # retq
  112. :getchar.getchar_fail
  113. 48 c7 c0 ff ff ff ff # mov $0xffffffffffffffff,%rax
  114. c3 # retq
  115. :putchar
  116. 88 04 25 98 01 60 00 # mov %al,0x600198
  117. 48 c7 c0 01 00 00 00 # mov $0x1,%rax
  118. 48 c7 c7 01 00 00 00 # mov $0x1,%rdi
  119. 48 8d 34 25 98 01 60 # lea 0x600198,%rsi
  120. 00
  121. 48 c7 c2 01 00 00 00 # mov $0x1,%rdx
  122. 0f 05 # syscall
  123. c3 # retq