elf32-0header.hex2 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. ### Copyright (C) 2016 Jeremiah Orians
  2. ### Copyright (C) 2017,2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
  3. ###
  4. ### This file is part of GNU Mes.
  5. ###
  6. ### GNU Mes is free software; you can redistribute it and/or modify it
  7. ### under the terms of the GNU General Public License as published by
  8. ### the Free Software Foundation; either version 3 of the License, or (at
  9. ### your option) any later version.
  10. ###
  11. ### GNU Mes is distributed in the hope that it will be useful, but
  12. ### WITHOUT ANY WARRANTY; without even the implied warranty of
  13. ### MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. ### GNU General Public License for more details.
  15. ###
  16. ### You should have received a copy of the GNU General Public License
  17. ### along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
  18. ### Commentary:
  19. # elf32-0header.hex2: Simplest 32 bit elf header in hex2. Only a text
  20. # segment, no data segment, no symbol tables.
  21. # stage0's hex2 format for x86
  22. # !<label> 1 byte relative
  23. # $<label> 2 byte address
  24. # @<label> 2 byte relative
  25. # &<label> 4 byte address
  26. # %<label> 4 byte relative
  27. # local_<label> function-local
  28. # string_<index> string #<index>
  29. ### Code:
  30. :ELF_base
  31. 7F 45 4C 46 # e_ident[EI_MAG0-3] ELF's magic number
  32. 01 # e_ident[EI_CLASS] Indicating 32 bit
  33. 01 # e_ident[EI_DATA] Indicating little endianness
  34. 01 # e_ident[EI_VERSION] Indicating original elf
  35. 00 # e_ident[EI_OSABI] Set at 0 because none cares
  36. 00 # e_ident[EI_ABIVERSION] See above
  37. 00 00 00 00 00 00 00 # e_ident[EI_PAD]
  38. 02 00 # e_type Indicating Executable
  39. 03 00 # e_machine Indicating 32bit x86
  40. 01 00 00 00 # e_version Indicating original elf
  41. &ELF_text # e_entry Address of the entry point
  42. %ELF_program_headers>ELF_base # e_phoff Address of program header table
  43. 00 00 00 00 # e_shoff Address of section header table
  44. 00 00 00 00 # e_flags
  45. 34 00 # e_ehsize Indicating our 52 Byte header
  46. 20 00 # e_phentsize size of a program header table
  47. 01 00 # e_phnum number of entries in program table
  48. 00 00 # e_shentsize size of a section header table
  49. 00 00 # e_shnum number of entries in section table
  50. 00 00 # e_shstrndx index of the section names
  51. # @34
  52. 00 00 00 00
  53. 00 00 00 00
  54. 00 00 00 00
  55. # @40
  56. :ELF_program_headers
  57. :ELF_program_header__text
  58. 01 00 00 00 # ph_type: PT-LOAD = 1
  59. 00 00 00 00 # ph_offset
  60. &ELF_base # ph_vaddr
  61. &ELF_base # ph_physaddr
  62. %ELF_end>ELF_base # ph_filesz
  63. %ELF_end>ELF_base # ph_memsz
  64. 07 00 00 00 # ph_flags: PF-X|PF-W|PF-R = 7
  65. 01 00 00 00 # ph_align
  66. # @60
  67. :ELF_text