boot2

Playing with the boostrap
git clone https://git.ryansepassi.com/git/boot2.git
Log | Files | Refs | README

ELF.hex2 (2625B)


      1 ### Copyright (C) 2016 Jeremiah Orians
      2 ### Copyright (C) 2017 Jan Nieuwenhuizen <janneke@gnu.org>
      3 ### This file is part of M2-Planet.
      4 ###
      5 ### M2-Planet 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 ### M2-Planet 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 M2-Planet.  If not, see <http://www.gnu.org/licenses/>.
     17 
     18 ### 64 bit elf header in hex2
     19 ### if you wish to use this header, you need to add :ELF_end to the end of your
     20 ### M1 or hex2 files.
     21 
     22 ## ELF Header
     23 
     24 :ELF_base
     25 7F 45 4C 46        ## e_ident[EI_MAG0-3] ELF's magic number
     26 
     27 02                 ## e_ident[EI_CLASS] Indicating 64 bit
     28 01                 ## e_ident[EI_DATA] Indicating little endianness
     29 01                 ## e_ident[EI_VERSION] Indicating original elf
     30 
     31 03                 ## e_ident[EI_OSABI] Set at 3 because FreeBSD is strict
     32 00                 ## e_ident[EI_ABIVERSION] Set at 0 because none cares
     33 
     34 00 00 00 00 00 00 00 ## e_ident[EI_PAD]
     35 02 00              ## e_type Indicating Executable
     36 F3 00              ## e_machine Indicating RISC-V
     37 01 00 00 00        ## e_version Indicating original elf
     38 
     39 &_start 00 00 00 00 ## e_entry Address of the entry point (Number of bytes this header is + Base Address)
     40 %ELF_program_headers>ELF_base 00 00 00 00 ## e_phoff Address of program header table
     41 00 00 00 00 00 00 00 00 ## e_shoff Address of section header table
     42 
     43 00 00 00 00        ## e_flags
     44 40 00              ## e_ehsize Indicating our 64 Byte header
     45 
     46 38 00              ## e_phentsize size of a program header table
     47 01 00              ## e_phnum number of entries in program table
     48 
     49 00 00              ## e_shentsize size of a section header table
     50 00 00              ## e_shnum number of entries in section table
     51 
     52 00 00              ## e_shstrndx index of the section names
     53 
     54 ## Program Header
     55 :ELF_program_headers
     56 01 00 00 00             ## p_type
     57 07 00 00 00             ## ph_flags: PF-X|PF-W|PF-R = 7
     58 00 00 00 00 00 00 00 00 ## p_offset
     59 
     60 &ELF_base 00 00 00 00 ## p_vaddr
     61 &ELF_base 00 00 00 00 ## p_physaddr
     62 
     63 %ELF_end>ELF_base 00 00 00 00 ## p_filesz
     64 00 00 80 00 00 00 00 00 ## p_memsz = 8 MB (boot2: BSS past ELF_end)
     65 
     66 01 00 00 00 00 00 00 00 ## Required alignment
     67 
     68 :ELF_text