elf32-debug.hex2 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  1. ### Copyright (C) 2016 Jeremiah Orians
  2. ### Copyright (C) 2017 Jan Nieuwenhuizen <janneke@gnu.org>
  3. ### This file is part of stage0.
  4. ###
  5. ### stage0 is free software: you can redistribute it and/or modify
  6. ### it under the terms of the GNU General Public License as published by
  7. ### the Free Software Foundation, either version 3 of the License, or
  8. ### (at your option) any later version.
  9. ###
  10. ### stage0 is distributed in the hope that it will be useful,
  11. ### but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ### MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. ### GNU General Public License for more details.
  14. ###
  15. ### You should have received a copy of the GNU General Public License
  16. ### along with stage0. If not, see <http://www.gnu.org/licenses/>.
  17. ### stage0's hex2 format for x86
  18. ### !<label> 1 byte relative
  19. ### $<label> 2 byte address
  20. ### @<label> 2 byte relative
  21. ### &<label> 4 byte address
  22. ### %<label> 4 byte relative
  23. ### local_<label> function-local
  24. ### string_<index> string #<index>
  25. ### elf32-header-exit-42.hex2: 32 bit elf header in hex2 for `exit 42'
  26. :ELF_base
  27. 7F 45 4C 46 # e_ident[EI_MAG0-3] ELF's magic number
  28. 01 # e_ident[EI_CLASS] Indicating 32 bit
  29. 01 # e_ident[EI_DATA] Indicating little endianness
  30. 01 # e_ident[EI_VERSION] Indicating original elf
  31. 00 # e_ident[EI_OSABI] Set at 0 because none cares
  32. 00 # e_ident[EI_ABIVERSION] See above
  33. 00 00 00 00 00 00 00 # e_ident[EI_PAD]
  34. 02 00 # e_type Indicating Executable
  35. 03 00 # e_machine Indicating AMD64
  36. 01 00 00 00 # e_version Indicating original elf
  37. &ELF_text # e_entry Address of the entry point
  38. %ELF_program_headers>ELF_base # e_phoff Address of program header table
  39. %ELF_section_headers>ELF_base # e_shoff Address of section header table
  40. 00 00 00 00 # e_flags
  41. 34 00 # e_ehsize Indicating our 52 Byte header
  42. 20 00 # e_phentsize size of a program header table
  43. 02 00 # e_phnum number of entries in program table
  44. 28 00 # e_shentsize size of a section header table
  45. 07 00 # e_shnum number of entries in section table
  46. 04 00 # e_shstrndx index of the section names
  47. # @34
  48. 00 00 00 00
  49. 00 00 00 00
  50. 00 00 00 00
  51. # @40
  52. :ELF_program_headers
  53. :ELF_program_header__text
  54. 01 00 00 00 # ph_type: PT-LOAD = 1
  55. 00 00 00 00 # ph_offset
  56. &ELF_base # ph_vaddr
  57. &ELF_base # ph_physaddr
  58. %ELF_end>ELF_base # ph_filesz
  59. %ELF_end>ELF_base # ph_memsz
  60. 07 00 00 00 # ph_flags: PF-X|PF-W|PF-R = 7
  61. 01 00 00 00 # ph_align
  62. # @60
  63. #:ELF_program_header__data # NOT USED
  64. # FIXME: linux 4.17 does not allow this overlap
  65. # Uhuuh, elf segment at 0000000001000000
  66. # requested but the memory is mapped already
  67. 00 00 00 00 # ph_type: PT-LOAD = 1 => no load
  68. 00 00 00 00 # ph_offset
  69. &ELF_base # ph_vaddr
  70. &ELF_base # ph_physaddr
  71. %ELF_end>ELF_base # ph_filesz
  72. %ELF_end>ELF_base # ph_memsz
  73. 07 00 00 00 # ph_flags: PF-X|PF-W|PF-R = 7
  74. 01 00 00 00 # ph_align
  75. # @80
  76. :ELF_comment
  77. 4d 45 53 00 # MES
  78. 00 00 00 00 # align
  79. 00 00 00 00
  80. 00 00 00 00
  81. 4d 45 53 00 # MES
  82. 00 00 00 00 # align
  83. 00 00 00 00
  84. 00 00 00 00
  85. # @a0
  86. :ELF_shstr
  87. 00
  88. :ELF_shstr__text
  89. 2e 74 65 78 74 00 # .text
  90. :ELF_shstr__data
  91. 2e 64 61 74 61 00 # .data
  92. :ELF_shstr__comment
  93. 2e 63 6f 6d 6d 65 6e 74 00 # .comment
  94. :ELF_shstr__shstr
  95. 2e 73 68 73 74 72 74 61 62 00 # .shstrtab
  96. :ELF_shstr__sym
  97. 2e 73 79 6d 74 61 62 00 # .symtab
  98. :ELF_shstr__str
  99. 2e 73 74 72 74 61 62 00 # .strtab
  100. # @d0
  101. :ELF_section_headers
  102. 00 00 00 00 # sh_name
  103. 00 00 00 00 # sh_type
  104. 00 00 00 00 # sh_flags
  105. 00 00 00 00 # sh_addr
  106. 00 00 00 00 # sh_offset
  107. 00 00 00 00 # sh_length
  108. 00 00 00 00 # sh_link
  109. 00 00 00 00 # sh_info
  110. 01 00 00 00 # sh_1?
  111. 00 00 00 00 # sh_entsize
  112. ## FIXME: M0 for calculations?
  113. :ELF_section_header_text
  114. %ELF_shstr__text>ELF_shstr # sh_name
  115. 01 00 00 00 # sh_type = SHT_PROGBITS = 1
  116. 06 00 00 00 # sh_flags = SHF-ALLOC|SHF-EXEC =2 | 4 = 6
  117. &ELF_text # sh_addr
  118. %ELF_text>ELF_base # sh_offset
  119. %ELF_data>ELF_text # sh_length
  120. 00 00 00 00 # sh_link
  121. 00 00 00 00 # sh_info
  122. 01 00 00 00 # sh_1?
  123. 00 00 00 00 # sh_entsize
  124. :ELF_section_header_data
  125. %ELF_shstr__data>ELF_shstr # sh_name
  126. 01 00 00 00 # sh_type = SHT_PROGBITS = 1
  127. 03 00 00 00 # sh_flags = SHF-WRITE|SHF-ALLOC = 1 | 2 = 3
  128. &ELF_data # sh_addr
  129. %ELF_data>ELF_base # sh_offset
  130. %ELF_sym>ELF_data # sh_length
  131. 00 00 00 00 # sh_link
  132. 00 00 00 00 # sh_info
  133. 01 00 00 00 # sh_1?
  134. 00 00 00 00 # sh_entsize
  135. :ELF_section_header_comment
  136. %ELF_shstr__comment>ELF_shstr # sh_name
  137. 01 00 00 00 # sh_type = SHT_PROGBITS = 1
  138. 00 00 00 00 # sh_flags
  139. &ELF_comment # sh_addr
  140. %ELF_comment>ELF_base # sh_offset
  141. %ELF_shstr>ELF_comment # sh_length
  142. 00 00 00 00 # sh_link
  143. 00 00 00 00 # sh_info
  144. 01 00 00 00 # sh_1?
  145. 00 00 00 00 # sh_entsize
  146. :ELF_section_header_shstr
  147. %ELF_shstr__shstr>ELF_shstr # sh_name
  148. 03 00 00 00 # sh_type: str-sht-strtab
  149. 00 00 00 00 # sh_flags
  150. &ELF_shstr # sh_addr
  151. %ELF_shstr>ELF_base # sh_offset
  152. %ELF_section_headers>ELF_shstr # sh_length
  153. 00 00 00 00 # sh_link
  154. 00 00 00 00 # sh_info
  155. 01 00 00 00 # sh_1?
  156. 00 00 00 00 # sh_entsize
  157. :ELF_section_header_sym
  158. %ELF_shstr__sym>ELF_shstr # sh_name
  159. 02 00 00 00 # sh_type: str-sht-symtab
  160. 00 00 00 00 # sh_flags
  161. &ELF_sym # sh_addr
  162. %ELF_sym>ELF_base # sh_offset
  163. %ELF_end>ELF_sym # sh_length
  164. 06 00 00 00 # sh_link:6
  165. 00 00 00 00 # sh_info
  166. 01 00 00 00 # sh_1?
  167. 10 00 00 00 # sh_entsize
  168. :ELF_section_header_str
  169. %ELF_shstr__str>ELF_shstr # sh_name
  170. 03 00 00 00 # sh_type: str-sht-strtab
  171. 00 00 00 00 # sh_flags
  172. &ELF_str # sh_addr
  173. %ELF_str>ELF_base # sh_offset
  174. %ELF_sym>ELF_str # sh_length
  175. 00 00 00 00 # sh_link
  176. 00 00 00 00 # sh_info
  177. 01 00 00 00 # sh_1?
  178. 00 00 00 00 # sh_entsize
  179. # @1e8
  180. 00 00 00 00 # align
  181. 00 00 00 00
  182. # @1f0
  183. 00 00 00 00 # align
  184. 00 00 00 00
  185. 00 00 00 00
  186. 00 00 00 00
  187. # @200
  188. :ELF_text