xeh.hex0 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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
  28. 40 00 00 00 00 00 00 00 ## e_phoff Address of program header table
  29. 30 01 00 00 00 00 00 00
  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. 18 01 00 00 00 00 00 00 ## p_filesz
  44. 18 01 00 00 00 00 00 00 ## p_memsz
  45. 00 00 20 00 00 00 00 00 ## Required alignment
  46. ## Start
  47. 48 c7 c2 01 00 00 00 # mov $0x1,%rdx
  48. 48 c7 c6 17 01 60 00 # mov $0x600117,%rsi
  49. 48 c7 c7 00 00 00 00 # mov $0x0,%rdi
  50. 48 c7 c0 00 00 00 00 # mov $0x0,%rax
  51. 0f 05 # syscall
  52. 48 85 c0 # test %rax,%rax
  53. 74 5b # je 6000f6 <Done>
  54. 8a 04 25 17 01 60 00 # mov 0x600117,%al
  55. 4c 0f b6 e0 # movzbq %al,%r12
  56. 4c 0f b6 e8 # movzbq %al,%r13
  57. 49 c1 ec 04 # shr $0x4,%r12
  58. 49 83 e5 0f # and $0xf,%r13
  59. 49 81 c4 06 01 60 00 # add $0x600106,%r12
  60. 49 81 c5 06 01 60 00 # add $0x600106,%r13
  61. 48 c7 c2 01 00 00 00 # mov $0x1,%rdx
  62. 4c 89 e6 # mov %r12,%rsi
  63. 48 c7 c7 01 00 00 00 # mov $0x1,%rdi
  64. 48 c7 c0 01 00 00 00 # mov $0x1,%rax
  65. 0f 05 # syscall
  66. 48 c7 c2 01 00 00 00 # mov $0x1,%rdx
  67. 4c 89 ee # mov %r13,%rsi
  68. 48 c7 c7 01 00 00 00 # mov $0x1,%rdi
  69. 48 c7 c0 01 00 00 00 # mov $0x1,%rax
  70. 0f 05 # syscall
  71. eb 82 # jmp 600078 <_start>
  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. ## Hex output chars
  77. 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 0A
  78. ## Where the byte we are reading is shoved
  79. 00