read.hex 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. ## Copyright (C) 2016 Jeremiah Orians
  2. ## This file is part of stage0.
  3. ##
  4. ## stage0 is free software: you an redistribute it and/or modify
  5. ## it under the terms of the GNU General Public License as published by
  6. ## the Free Software Foundation, either version 3 of the License, or
  7. ## (at your option) any later version.
  8. ##
  9. ## stage0 is distributed in the hope that it will be useful,
  10. ## but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. ## GNU General Public License for more details.
  13. ##
  14. ## You should have received a copy of the GNU General Public License
  15. ## along with stage0. If not, see <http://www.gnu.org/licenses/>.
  16. # ELF Header
  17. 7F 45 4C 46 ## e_ident[EI_MAG0-3] ELF's magic number
  18. 02 ## e_ident[EI_CLASS] Indicating 64 bit
  19. 01 ## e_ident[EI_DATA] Indicating little endianness
  20. 01 ## e_ident[EI_VERSION] Indicating original elf
  21. 00 ## e_ident[EI_OSABI] Set at 0 because none cares
  22. 00 ## e_ident[EI_ABIVERSION] See above
  23. 00 00 00 00 00 00 00 ## e_ident[EI_PAD]
  24. 02 00 ## e_type Indicating Executable
  25. 3E 00 ## e_machine Indicating AMD64
  26. 01 00 00 00 ## e_version Indicating original elf
  27. 78 00 60 00 00 00 00 00 ## e_entry Address of the entry point
  28. 40 00 00 00 00 00 00 00 ## e_phoff Address of program header table
  29. 00 00 00 00 00 00 00 00 ## e_shoff Address of section header table
  30. 00 00 00 00 ## e_flags
  31. 40 00 ## e_ehsize Indicating our 64 Byte header
  32. 38 00 ## e_phentsize size of a program header table
  33. 01 00 ## e_phnum number of entries in program table
  34. 00 00 ## e_shentsize size of a section header table
  35. 00 00 ## e_shnum number of entries in section table
  36. 00 00 ## e_shstrndx index of the section names
  37. # Program Header Table
  38. 01 00 00 00 ## p_type
  39. 06 00 00 00 ## Flags
  40. 00 00 00 00 00 00 00 00 ## p_offset
  41. 00 00 60 00 00 00 00 00 ## p_vaddr
  42. 00 00 00 00 00 00 00 00 ## Undefined
  43. F1 00 00 00 00 00 00 00 ## p_filesz
  44. F1 00 00 00 00 00 00 00 ## p_memsz
  45. 00 00 20 00 00 00 00 00 ## Required alignment
  46. # Start
  47. 58 # pop %rax
  48. 5f # pop %rdi
  49. 5f # pop %rdi
  50. 48 83 f8 02 # cmp $0x2,%rax
  51. 75 5f # jne 6000e0 <Bail>
  52. 48 c7 c6 00 00 00 00 # mov $0x0,%rsi
  53. 48 c7 c0 02 00 00 00 # mov $0x2,%rax
  54. 0f 05 # syscall
  55. 48 85 c0 # test %rax,%rax
  56. 78 4a # js 6000e0 <Bail>
  57. 48 89 c7 # mov %rax,%rdi
  58. # Circle
  59. 48 c7 c2 00 00 00 40 # mov $0x40000000,%rdx
  60. 48 c7 c6 f0 00 60 00 # mov $0x6000f0,%rsi
  61. 48 c7 c0 00 00 00 00 # mov $0x0,%rax
  62. 0f 05 # syscall
  63. 48 85 c0 # test %rax,%rax
  64. 74 1b # je 6000d0 <Done>
  65. 48 89 c2 # mov %rax,%rdx
  66. 48 89 fc # mov %rdi,%rsp
  67. 48 c7 c7 01 00 00 00 # mov $0x1,%rdi
  68. 48 c7 c0 01 00 00 00 # mov $0x1,%rax
  69. 0f 05 # syscall
  70. 48 89 e7 # mov %rsp,%rdi
  71. eb c9 # jmp 600099 <Circle>
  72. # Done
  73. 48 c7 c7 00 00 00 00 # mov $0x0,%rdi
  74. 48 c7 c0 3c 00 00 00 # mov $0x3c,%rax
  75. 0f 05 # syscall
  76. # Bail
  77. 48 c7 c7 01 00 00 00 # mov $0x0,%rdi
  78. 48 c7 c0 3c 00 00 00 # mov $0x3c,%rax
  79. 0f 05 # syscall