exec_enable.hex 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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. ## Exec_enable program
  17. ## Takes only single arg
  18. ## Shitty to use but essential if you need it
  19. ## ELF Header
  20. 7F 45 4C 46 ## e_ident[EI_MAG0-3] ELF's magic number
  21. 02 ## e_ident[EI_CLASS] Indicating 64 bit
  22. 01 ## e_ident[EI_DATA] Indicating little endianness
  23. 01 ## e_ident[EI_VERSION] Indicating original elf
  24. 00 ## e_ident[EI_OSABI] Set at 0 because none cares
  25. 00 ## e_ident[EI_ABIVERSION] See above
  26. 00 00 00 00 00 00 00 ## e_ident[EI_PAD]
  27. 02 00 ## e_type Indicating Executable
  28. 3E 00 ## e_machine Indicating AMD64
  29. 01 00 00 00 ## e_version Indicating original elf
  30. 78 00 40 00 00 00 00 00 ## e_entry Address of the entry point
  31. 40 00 00 00 00 00 00 00 ## e_phoff Address of program header table
  32. F0 01 00 00 00 00 00 00 ## e_shoff Address of section header table
  33. 00 00 00 00 ## e_flags
  34. 40 00 ## e_ehsize Indicating our 64 Byte header
  35. 38 00 ## e_phentsize size of a program header table
  36. 01 00 ## e_phnum number of entries in program table
  37. 00 00 ## e_shentsize size of a section header table
  38. 00 00 ## e_shnum number of entries in section table
  39. 00 00 ## e_shstrndx index of the section names
  40. ## Program Header
  41. 01 00 00 00 ## p_type
  42. 05 00 00 00 ## Flags
  43. 00 00 00 00 00 00 00 00 ## p_offset
  44. 00 00 40 00 00 00 00 00 ## p_vaddr
  45. 00 00 00 00 00 00 00 00 ## Undefined
  46. B1 00 00 00 00 00 00 00 ## p_filesz
  47. B1 00 00 00 00 00 00 00 ## p_memsz
  48. 00 00 20 00 00 00 00 00 ## Required alignment
  49. ## Start
  50. 58 # pop %rax
  51. 5f # pop %rdi
  52. 5f # pop %rdi
  53. 48 83 f8 02 # cmp $0x2,%rax
  54. 75 20 # jne 4000a1 <Bail>
  55. 48 c7 c6 ed 01 00 00 # mov $0x1ed,%rsi
  56. 48 c7 c0 5a 00 00 00 # mov $0x5a,%rax
  57. 0f 05 # syscall
  58. ## Done
  59. 48 c7 c7 00 00 00 00 # mov $0x0,%rdi
  60. 48 c7 c0 3c 00 00 00 # mov $0x3c,%rax
  61. 0f 05 # syscall
  62. ## Bail
  63. 48 c7 c7 01 00 00 00 # mov $0x1,%rdi
  64. 48 c7 c0 3c 00 00 00 # mov $0x3c,%rax
  65. 0f 05 # syscall