minimal-bootstrap.stage0-posix: support x86_64-linux

+231 -174
-8
pkgs/os-specific/linux/minimal-bootstrap/stage0-posix/bootstrap-sources.nix
··· 9 outputHashAlgo = "sha256"; 10 outputHash = "sha256-FpMp7z+B3cR3LkQ+PooH/b1/NlxH8NHVJNWifaPWt4U="; 11 12 - # This 256 byte seed is the only pre-compiled binary in the bootstrap chain. 13 - hex0-seed = import <nix/fetchurl.nix> { 14 - name = "hex0-seed-${version}"; 15 - url = "https://github.com/oriansj/bootstrap-seeds/raw/b1263ff14a17835f4d12539226208c426ced4fba/POSIX/x86/hex0-seed"; 16 - hash = "sha256-QU3RPGy51W7M2xnfFY1IqruKzusrSLU+L190ztN6JW8="; 17 - executable = true; 18 - }; 19 - 20 /* 21 Since `make-minimal-bootstrap-sources` requires nixpkgs and nix it 22 will create a circular dependency if it is used in place of the
··· 9 outputHashAlgo = "sha256"; 10 outputHash = "sha256-FpMp7z+B3cR3LkQ+PooH/b1/NlxH8NHVJNWifaPWt4U="; 11 12 /* 13 Since `make-minimal-bootstrap-sources` requires nixpkgs and nix it 14 will create a circular dependency if it is used in place of the
+6 -4
pkgs/os-specific/linux/minimal-bootstrap/stage0-posix/default.nix
··· 3 }: 4 5 lib.makeScope newScope (self: with self; { 6 - inherit (self.callPackage ./bootstrap-sources.nix {}) 7 - version hex0-seed minimal-bootstrap-sources; 8 9 src = minimal-bootstrap-sources; 10 11 m2libc = src + "/M2libc"; 12 13 hex0 = callPackage ./hex0.nix { }; 14 15 kaem = callPackage ./kaem { }; 16 kaem-minimal = callPackage ./kaem/minimal.nix { }; 17 18 - stage0-posix-x86 = callPackage ./stage0-posix-x86.nix { }; 19 20 - inherit (self.stage0-posix-x86) blood-elf-0 hex2 kaem-unwrapped M1 M2; 21 22 mescc-tools = callPackage ./mescc-tools { }; 23
··· 3 }: 4 5 lib.makeScope newScope (self: with self; { 6 + inherit (callPackage ./platforms.nix { }) platforms stage0Arch m2libcArch m2libcOS baseAddress; 7 + 8 + inherit (self.callPackage ./bootstrap-sources.nix {}) version minimal-bootstrap-sources; 9 10 src = minimal-bootstrap-sources; 11 12 m2libc = src + "/M2libc"; 13 14 hex0 = callPackage ./hex0.nix { }; 15 + inherit (self.hex0) hex0-seed; 16 17 kaem = callPackage ./kaem { }; 18 kaem-minimal = callPackage ./kaem/minimal.nix { }; 19 20 + mescc-tools-boot = callPackage ./mescc-tools-boot.nix { }; 21 22 + inherit (self.mescc-tools-boot) blood-elf-0 hex2 kaem-unwrapped M1 M2; 23 24 mescc-tools = callPackage ./mescc-tools { }; 25
+24 -4
pkgs/os-specific/linux/minimal-bootstrap/stage0-posix/hex0.nix
··· 1 { lib 2 , derivationWithMeta 3 - , hex0-seed 4 , src 5 , version 6 }: 7 derivationWithMeta { 8 inherit version; 9 pname = "hex0"; 10 builder = hex0-seed; 11 args = [ 12 - "${src}/x86/hex0_x86.hex0" 13 (placeholder "out") 14 ]; 15 ··· 18 homepage = "https://github.com/oriansj/stage0-posix"; 19 license = licenses.gpl3Plus; 20 maintainers = teams.minimal-bootstrap.members; 21 - platforms = [ "i686-linux" ]; 22 }; 23 24 # Ensure the untrusted hex0-seed binary produces a known-good hex0 25 outputHashMode = "recursive"; 26 outputHashAlgo = "sha256"; 27 - outputHash = "sha256-QU3RPGy51W7M2xnfFY1IqruKzusrSLU+L190ztN6JW8="; 28 }
··· 1 { lib 2 , derivationWithMeta 3 + , hostPlatform 4 , src 5 , version 6 + , platforms 7 + , stage0Arch 8 }: 9 + 10 + let 11 + hash = { 12 + "x86" = "sha256-QU3RPGy51W7M2xnfFY1IqruKzusrSLU+L190ztN6JW8="; 13 + "AMD64" = "sha256-RCgK9oZRDQUiWLVkcIBSR2HeoB+Bh0czthrpjFEkCaY="; 14 + }.${stage0Arch} or (throw "Unsupported system: ${hostPlatform.system}"); 15 + 16 + # Pinned from https://github.com/oriansj/stage0-posix/commit/3189b5f325b7ef8b88e3edec7c1cde4fce73c76c 17 + # This 256 byte seed is the only pre-compiled binary in the bootstrap chain. 18 + hex0-seed = import <nix/fetchurl.nix> { 19 + name = "hex0-seed"; 20 + url = "https://github.com/oriansj/bootstrap-seeds/raw/b1263ff14a17835f4d12539226208c426ced4fba/POSIX/${stage0Arch}/hex0-seed"; 21 + executable = true; 22 + inherit hash; 23 + }; 24 + in 25 derivationWithMeta { 26 inherit version; 27 pname = "hex0"; 28 builder = hex0-seed; 29 args = [ 30 + "${src}/${stage0Arch}/hex0_${stage0Arch}.hex0" 31 (placeholder "out") 32 ]; 33 ··· 36 homepage = "https://github.com/oriansj/stage0-posix"; 37 license = licenses.gpl3Plus; 38 maintainers = teams.minimal-bootstrap.members; 39 + inherit platforms; 40 }; 41 42 + passthru = { inherit hex0-seed; }; 43 + 44 # Ensure the untrusted hex0-seed binary produces a known-good hex0 45 outputHashMode = "recursive"; 46 outputHashAlgo = "sha256"; 47 + outputHash = hash; 48 }
+2 -1
pkgs/os-specific/linux/minimal-bootstrap/stage0-posix/kaem/default.nix
··· 6 , mescc-tools 7 , mescc-tools-extra 8 , version 9 }: 10 11 # Once mescc-tools-extra is available we can install kaem at /bin/kaem ··· 46 homepage = "https://github.com/oriansj/mescc-tools"; 47 license = licenses.gpl3Plus; 48 maintainers = teams.minimal-bootstrap.members; 49 - platforms = [ "i686-linux" ]; 50 }; 51 }
··· 6 , mescc-tools 7 , mescc-tools-extra 8 , version 9 + , platforms 10 }: 11 12 # Once mescc-tools-extra is available we can install kaem at /bin/kaem ··· 47 homepage = "https://github.com/oriansj/mescc-tools"; 48 license = licenses.gpl3Plus; 49 maintainers = teams.minimal-bootstrap.members; 50 + inherit platforms; 51 }; 52 }
+4 -2
pkgs/os-specific/linux/minimal-bootstrap/stage0-posix/kaem/minimal.nix
··· 3 , src 4 , hex0 5 , version 6 }: 7 derivationWithMeta { 8 inherit version; 9 pname = "kaem-minimal"; 10 builder = hex0; 11 args = [ 12 - "${src}/x86/kaem-minimal.hex0" 13 (placeholder "out") 14 ]; 15 ··· 18 homepage = "https://github.com/oriansj/stage0-posix"; 19 license = licenses.gpl3Plus; 20 maintainers = teams.minimal-bootstrap.members; 21 - platforms = [ "i686-linux" ]; 22 }; 23 } 24
··· 3 , src 4 , hex0 5 , version 6 + , platforms 7 + , stage0Arch 8 }: 9 derivationWithMeta { 10 inherit version; 11 pname = "kaem-minimal"; 12 builder = hex0; 13 args = [ 14 + "${src}/${stage0Arch}/kaem-minimal.hex0" 15 (placeholder "out") 16 ]; 17 ··· 20 homepage = "https://github.com/oriansj/stage0-posix"; 21 license = licenses.gpl3Plus; 22 maintainers = teams.minimal-bootstrap.members; 23 + inherit platforms; 24 }; 25 } 26
+1 -1
pkgs/os-specific/linux/minimal-bootstrap/stage0-posix/mescc-tools-extra/build.kaem
··· 19 ## You should have received a copy of the GNU General Public License 20 ## along with mescc-tools. If not, see <http://www.gnu.org/licenses/>. 21 22 - alias CC="${mescc-tools}/bin/M2-Mesoplanet --operating-system ${OPERATING_SYSTEM} --architecture ${ARCH} -f" 23 cd ${src}/mescc-tools-extra 24 25 # Create output folder
··· 19 ## You should have received a copy of the GNU General Public License 20 ## along with mescc-tools. If not, see <http://www.gnu.org/licenses/>. 21 22 + alias CC="${mescc-tools}/bin/M2-Mesoplanet --operating-system ${m2libcOS} --architecture ${m2libcArch} -f" 23 cd ${src}/mescc-tools-extra 24 25 # Create output folder
+5 -5
pkgs/os-specific/linux/minimal-bootstrap/stage0-posix/mescc-tools-extra/default.nix
··· 4 , mescc-tools 5 , src 6 , version 7 }: 8 derivationWithMeta { 9 - inherit version src mescc-tools; 10 pname = "mescc-tools-extra"; 11 builder = kaem-unwrapped; 12 args = [ ··· 16 ./build.kaem 17 ]; 18 19 - ARCH = "x86"; 20 - OPERATING_SYSTEM = "linux"; 21 - 22 meta = with lib; { 23 description = "Collection of tools written for use in bootstrapping"; 24 homepage = "https://github.com/oriansj/mescc-tools-extra"; 25 license = licenses.gpl3Plus; 26 maintainers = teams.minimal-bootstrap.members; 27 - platforms = [ "i686-linux" ]; 28 }; 29 }
··· 4 , mescc-tools 5 , src 6 , version 7 + , platforms 8 + , m2libcArch 9 + , m2libcOS 10 }: 11 derivationWithMeta { 12 + inherit version src mescc-tools m2libcArch m2libcOS; 13 pname = "mescc-tools-extra"; 14 builder = kaem-unwrapped; 15 args = [ ··· 19 ./build.kaem 20 ]; 21 22 meta = with lib; { 23 description = "Collection of tools written for use in bootstrapping"; 24 homepage = "https://github.com/oriansj/mescc-tools-extra"; 25 license = licenses.gpl3Plus; 26 maintainers = teams.minimal-bootstrap.members; 27 + inherit platforms; 28 }; 29 }
+50 -50
pkgs/os-specific/linux/minimal-bootstrap/stage0-posix/mescc-tools/build.kaem
··· 46 # Phase-12 Build M2-Mesoplanet from M2-Planet # 47 ############################################### 48 49 - ${M2} --architecture ${ARCH} \ 50 -f ${m2libc}/sys/types.h \ 51 -f ${m2libc}/stddef.h \ 52 - -f ${m2libc}/${ARCH}/linux/fcntl.c \ 53 -f ${m2libc}/fcntl.c \ 54 - -f ${m2libc}/${ARCH}/linux/unistd.c \ 55 - -f ${m2libc}/${ARCH}/linux/sys/stat.c \ 56 -f ${m2libc}/stdlib.c \ 57 -f ${m2libc}/stdio.h \ 58 -f ${m2libc}/stdio.c \ ··· 69 --debug \ 70 -o ./M2-Mesoplanet-1.M1 71 72 - ${blood-elf-0} ${ENDIAN_FLAG} ${BLOOD_FLAG} -f ./M2-Mesoplanet-1.M1 -o ./M2-Mesoplanet-1-footer.M1 73 74 - ${M1} --architecture ${ARCH} \ 75 - ${ENDIAN_FLAG} \ 76 - -f ${m2libc}/${ARCH}/${ARCH}_defs.M1 \ 77 - -f ${m2libc}/${ARCH}/libc-full.M1 \ 78 -f ./M2-Mesoplanet-1.M1 \ 79 -f ./M2-Mesoplanet-1-footer.M1 \ 80 -o ./M2-Mesoplanet-1.hex2 81 82 - ${hex2} --architecture ${ARCH} \ 83 - ${ENDIAN_FLAG} \ 84 - --base-address ${BASE_ADDRESS} \ 85 - -f ${m2libc}/${ARCH}/ELF-${ARCH}-debug.hex2 \ 86 -f ./M2-Mesoplanet-1.hex2 \ 87 -o ${out}/bin/M2-Mesoplanet 88 ··· 90 # Phase-13 Build final blood-elf from C sources # 91 ################################################# 92 93 - ${M2} --architecture ${ARCH} \ 94 -f ${m2libc}/sys/types.h \ 95 -f ${m2libc}/stddef.h \ 96 - -f ${m2libc}/${ARCH}/linux/fcntl.c \ 97 -f ${m2libc}/fcntl.c \ 98 - -f ${m2libc}/${ARCH}/linux/unistd.c \ 99 -f ${m2libc}/stdlib.c \ 100 -f ${m2libc}/stdio.h \ 101 -f ${m2libc}/stdio.c \ ··· 105 --debug \ 106 -o ./blood-elf-1.M1 107 108 - ${blood-elf-0} ${BLOOD_FLAG} ${ENDIAN_FLAG} -f ./blood-elf-1.M1 -o ./blood-elf-1-footer.M1 109 - ${M1} --architecture ${ARCH} \ 110 - ${ENDIAN_FLAG} \ 111 - -f ${m2libc}/${ARCH}/${ARCH}_defs.M1 \ 112 - -f ${m2libc}/${ARCH}/libc-full.M1 \ 113 -f ./blood-elf-1.M1 \ 114 -f ./blood-elf-1-footer.M1 \ 115 -o ./blood-elf-1.hex2 116 117 - ${hex2} --architecture ${ARCH} \ 118 - ${ENDIAN_FLAG} \ 119 - --base-address ${BASE_ADDRESS} \ 120 - -f ${m2libc}/${ARCH}/ELF-${ARCH}-debug.hex2 \ 121 -f ./blood-elf-1.hex2 \ 122 -o ${out}/bin/blood-elf 123 ··· 129 # Phase-14 Build get_machine from C sources # 130 ############################################# 131 132 - ${M2} --architecture ${ARCH} \ 133 -f ${m2libc}/sys/types.h \ 134 -f ${m2libc}/stddef.h \ 135 - -f ${m2libc}/${ARCH}/linux/unistd.c \ 136 - -f ${m2libc}/${ARCH}/linux/fcntl.c \ 137 -f ${m2libc}/fcntl.c \ 138 -f ${m2libc}/stdlib.c \ 139 -f ${m2libc}/stdio.h \ ··· 143 --debug \ 144 -o get_machine.M1 145 146 - ${out}/bin/blood-elf ${BLOOD_FLAG} ${ENDIAN_FLAG} -f ./get_machine.M1 -o ./get_machine-footer.M1 147 148 - ${M1} --architecture ${ARCH} \ 149 - ${ENDIAN_FLAG} \ 150 - -f ${m2libc}/${ARCH}/${ARCH}_defs.M1 \ 151 - -f ${m2libc}/${ARCH}/libc-full.M1 \ 152 -f ./get_machine.M1 \ 153 -f ./get_machine-footer.M1 \ 154 -o ./get_machine.hex2 155 156 - ${hex2} --architecture ${ARCH} \ 157 - ${ENDIAN_FLAG} \ 158 - --base-address ${BASE_ADDRESS} \ 159 - -f ${m2libc}/${ARCH}/ELF-${ARCH}-debug.hex2 \ 160 -f ./get_machine.hex2 \ 161 -o ${out}/bin/get_machine 162 ··· 164 # Phase-15 Build M2-Planet from M2-Planet # 165 ############################################ 166 167 - ${M2} --architecture ${ARCH} \ 168 -f ${m2libc}/sys/types.h \ 169 -f ${m2libc}/stddef.h \ 170 - -f ${m2libc}/${ARCH}/linux/unistd.c \ 171 - -f ${m2libc}/${ARCH}/linux/fcntl.c \ 172 -f ${m2libc}/fcntl.c \ 173 -f ${m2libc}/stdlib.c \ 174 -f ${m2libc}/stdio.h \ ··· 185 --debug \ 186 -o ./M2-1.M1 187 188 - ${out}/bin/blood-elf ${ENDIAN_FLAG} ${BLOOD_FLAG} -f ./M2-1.M1 -o ./M2-1-footer.M1 189 190 - ${M1} --architecture ${ARCH} \ 191 - ${ENDIAN_FLAG} \ 192 - -f ${m2libc}/${ARCH}/${ARCH}_defs.M1 \ 193 - -f ${m2libc}/${ARCH}/libc-full.M1 \ 194 -f ./M2-1.M1 \ 195 -f ./M2-1-footer.M1 \ 196 -o ./M2-1.hex2 197 198 - ${hex2} --architecture ${ARCH} \ 199 - ${ENDIAN_FLAG} \ 200 - --base-address ${BASE_ADDRESS} \ 201 - -f ${m2libc}/${ARCH}/ELF-${ARCH}-debug.hex2 \ 202 -f ./M2-1.hex2 \ 203 -o ${out}/bin/M2-Planet 204 -
··· 46 # Phase-12 Build M2-Mesoplanet from M2-Planet # 47 ############################################### 48 49 + ${M2} --architecture ${m2libcArch} \ 50 -f ${m2libc}/sys/types.h \ 51 -f ${m2libc}/stddef.h \ 52 + -f ${m2libc}/${m2libcArch}/linux/fcntl.c \ 53 -f ${m2libc}/fcntl.c \ 54 + -f ${m2libc}/${m2libcArch}/linux/unistd.c \ 55 + -f ${m2libc}/${m2libcArch}/linux/sys/stat.c \ 56 -f ${m2libc}/stdlib.c \ 57 -f ${m2libc}/stdio.h \ 58 -f ${m2libc}/stdio.c \ ··· 69 --debug \ 70 -o ./M2-Mesoplanet-1.M1 71 72 + ${blood-elf-0} ${endianFlag} ${bloodFlag} -f ./M2-Mesoplanet-1.M1 -o ./M2-Mesoplanet-1-footer.M1 73 74 + ${M1} --architecture ${m2libcArch} \ 75 + ${endianFlag} \ 76 + -f ${m2libc}/${m2libcArch}/${m2libcArch}_defs.M1 \ 77 + -f ${m2libc}/${m2libcArch}/libc-full.M1 \ 78 -f ./M2-Mesoplanet-1.M1 \ 79 -f ./M2-Mesoplanet-1-footer.M1 \ 80 -o ./M2-Mesoplanet-1.hex2 81 82 + ${hex2} --architecture ${m2libcArch} \ 83 + ${endianFlag} \ 84 + --base-address ${baseAddress} \ 85 + -f ${m2libc}/${m2libcArch}/ELF-${m2libcArch}-debug.hex2 \ 86 -f ./M2-Mesoplanet-1.hex2 \ 87 -o ${out}/bin/M2-Mesoplanet 88 ··· 90 # Phase-13 Build final blood-elf from C sources # 91 ################################################# 92 93 + ${M2} --architecture ${m2libcArch} \ 94 -f ${m2libc}/sys/types.h \ 95 -f ${m2libc}/stddef.h \ 96 + -f ${m2libc}/${m2libcArch}/linux/fcntl.c \ 97 -f ${m2libc}/fcntl.c \ 98 + -f ${m2libc}/${m2libcArch}/linux/unistd.c \ 99 -f ${m2libc}/stdlib.c \ 100 -f ${m2libc}/stdio.h \ 101 -f ${m2libc}/stdio.c \ ··· 105 --debug \ 106 -o ./blood-elf-1.M1 107 108 + ${blood-elf-0} ${endianFlag} ${bloodFlag} -f ./blood-elf-1.M1 -o ./blood-elf-1-footer.M1 109 + 110 + ${M1} --architecture ${m2libcArch} \ 111 + ${endianFlag} \ 112 + -f ${m2libc}/${m2libcArch}/${m2libcArch}_defs.M1 \ 113 + -f ${m2libc}/${m2libcArch}/libc-full.M1 \ 114 -f ./blood-elf-1.M1 \ 115 -f ./blood-elf-1-footer.M1 \ 116 -o ./blood-elf-1.hex2 117 118 + ${hex2} --architecture ${m2libcArch} \ 119 + ${endianFlag} \ 120 + --base-address ${baseAddress} \ 121 + -f ${m2libc}/${m2libcArch}/ELF-${m2libcArch}-debug.hex2 \ 122 -f ./blood-elf-1.hex2 \ 123 -o ${out}/bin/blood-elf 124 ··· 130 # Phase-14 Build get_machine from C sources # 131 ############################################# 132 133 + ${M2} --architecture ${m2libcArch} \ 134 -f ${m2libc}/sys/types.h \ 135 -f ${m2libc}/stddef.h \ 136 + -f ${m2libc}/${m2libcArch}/linux/unistd.c \ 137 + -f ${m2libc}/${m2libcArch}/linux/fcntl.c \ 138 -f ${m2libc}/fcntl.c \ 139 -f ${m2libc}/stdlib.c \ 140 -f ${m2libc}/stdio.h \ ··· 144 --debug \ 145 -o get_machine.M1 146 147 + ${out}/bin/blood-elf ${endianFlag} ${bloodFlag} -f ./get_machine.M1 -o ./get_machine-footer.M1 148 149 + ${M1} --architecture ${m2libcArch} \ 150 + ${endianFlag} \ 151 + -f ${m2libc}/${m2libcArch}/${m2libcArch}_defs.M1 \ 152 + -f ${m2libc}/${m2libcArch}/libc-full.M1 \ 153 -f ./get_machine.M1 \ 154 -f ./get_machine-footer.M1 \ 155 -o ./get_machine.hex2 156 157 + ${hex2} --architecture ${m2libcArch} \ 158 + ${endianFlag} \ 159 + --base-address ${baseAddress} \ 160 + -f ${m2libc}/${m2libcArch}/ELF-${m2libcArch}-debug.hex2 \ 161 -f ./get_machine.hex2 \ 162 -o ${out}/bin/get_machine 163 ··· 165 # Phase-15 Build M2-Planet from M2-Planet # 166 ############################################ 167 168 + ${M2} --architecture ${m2libcArch} \ 169 -f ${m2libc}/sys/types.h \ 170 -f ${m2libc}/stddef.h \ 171 + -f ${m2libc}/${m2libcArch}/linux/unistd.c \ 172 + -f ${m2libc}/${m2libcArch}/linux/fcntl.c \ 173 -f ${m2libc}/fcntl.c \ 174 -f ${m2libc}/stdlib.c \ 175 -f ${m2libc}/stdio.h \ ··· 186 --debug \ 187 -o ./M2-1.M1 188 189 + ${out}/bin/blood-elf ${endianFlag} ${bloodFlag} -f ./M2-1.M1 -o ./M2-1-footer.M1 190 191 + ${M1} --architecture ${m2libcArch} \ 192 + ${endianFlag} \ 193 + -f ${m2libc}/${m2libcArch}/${m2libcArch}_defs.M1 \ 194 + -f ${m2libc}/${m2libcArch}/libc-full.M1 \ 195 -f ./M2-1.M1 \ 196 -f ./M2-1-footer.M1 \ 197 -o ./M2-1.hex2 198 199 + ${hex2} --architecture ${m2libcArch} \ 200 + ${endianFlag} \ 201 + --base-address ${baseAddress} \ 202 + -f ${m2libc}/${m2libcArch}/ELF-${m2libcArch}-debug.hex2 \ 203 -f ./M2-1.hex2 \ 204 -o ${out}/bin/M2-Planet
+22 -20
pkgs/os-specific/linux/minimal-bootstrap/stage0-posix/mescc-tools/default.nix
··· 1 { lib 2 , derivationWithMeta 3 , kaem-unwrapped 4 , M1 5 , M2 ··· 8 , m2libc 9 , src 10 , version 11 }: 12 13 let 14 - ARCH = "x86"; 15 - BLOOD_FLAG = " "; 16 - BASE_ADDRESS = "0x8048000"; 17 - ENDIAN_FLAG = "--little-endian"; 18 19 # We need a few tools from mescc-tools-extra to assemble the output folder 20 buildMesccToolsExtraUtil = name: ··· 26 "--strict" 27 "--file" 28 (builtins.toFile "build-${name}.kaem" '' 29 - ''${M2} --architecture ''${ARCH} \ 30 -f ''${m2libc}/sys/types.h \ 31 -f ''${m2libc}/stddef.h \ 32 - -f ''${m2libc}/''${ARCH}/linux/fcntl.c \ 33 -f ''${m2libc}/fcntl.c \ 34 - -f ''${m2libc}/''${ARCH}/linux/unistd.c \ 35 - -f ''${m2libc}/''${ARCH}/linux/sys/stat.c \ 36 -f ''${m2libc}/stdlib.c \ 37 -f ''${m2libc}/stdio.h \ 38 -f ''${m2libc}/stdio.c \ ··· 42 --debug \ 43 -o ${name}.M1 44 45 - ''${blood-elf-0} ''${ENDIAN_FLAG} -f ${name}.M1 -o ${name}-footer.M1 46 47 - ''${M1} --architecture ''${ARCH} \ 48 - ''${ENDIAN_FLAG} \ 49 - -f ''${m2libc}/''${ARCH}/''${ARCH}_defs.M1 \ 50 - -f ''${m2libc}/''${ARCH}/libc-full.M1 \ 51 -f ${name}.M1 \ 52 -f ${name}-footer.M1 \ 53 -o ${name}.hex2 54 55 - ''${hex2} --architecture ''${ARCH} \ 56 - ''${ENDIAN_FLAG} \ 57 - -f ''${m2libc}/''${ARCH}/ELF-''${ARCH}-debug.hex2 \ 58 -f ${name}.hex2 \ 59 - --base-address ''${BASE_ADDRESS} \ 60 -o ''${out} 61 '') 62 ]; 63 - inherit version M1 M2 blood-elf-0 hex2 m2libc src ARCH BLOOD_FLAG BASE_ADDRESS ENDIAN_FLAG; 64 }; 65 mkdir = buildMesccToolsExtraUtil "mkdir"; 66 cp = buildMesccToolsExtraUtil "cp"; ··· 76 "--file" 77 ./build.kaem 78 ]; 79 - inherit version M1 M2 blood-elf-0 hex2 mkdir cp chmod replace m2libc src ARCH BLOOD_FLAG BASE_ADDRESS ENDIAN_FLAG; 80 81 meta = with lib; { 82 description = "Collection of tools written for use in bootstrapping"; 83 homepage = "https://github.com/oriansj/mescc-tools"; 84 license = licenses.gpl3Plus; 85 maintainers = teams.minimal-bootstrap.members; 86 - platforms = [ "i686-linux" ]; 87 }; 88 }
··· 1 { lib 2 , derivationWithMeta 3 + , hostPlatform 4 , kaem-unwrapped 5 , M1 6 , M2 ··· 9 , m2libc 10 , src 11 , version 12 + , platforms 13 + , m2libcArch 14 + , baseAddress 15 }: 16 17 let 18 + endianFlag = if hostPlatform.isLittleEndian then "--little-endian" else "--big-endian"; 19 + bloodFlag = if hostPlatform.is64bit then "--64" else " "; 20 21 # We need a few tools from mescc-tools-extra to assemble the output folder 22 buildMesccToolsExtraUtil = name: ··· 28 "--strict" 29 "--file" 30 (builtins.toFile "build-${name}.kaem" '' 31 + ''${M2} --architecture ${m2libcArch} \ 32 -f ''${m2libc}/sys/types.h \ 33 -f ''${m2libc}/stddef.h \ 34 + -f ''${m2libc}/${m2libcArch}/linux/fcntl.c \ 35 -f ''${m2libc}/fcntl.c \ 36 + -f ''${m2libc}/${m2libcArch}/linux/unistd.c \ 37 + -f ''${m2libc}/${m2libcArch}/linux/sys/stat.c \ 38 -f ''${m2libc}/stdlib.c \ 39 -f ''${m2libc}/stdio.h \ 40 -f ''${m2libc}/stdio.c \ ··· 44 --debug \ 45 -o ${name}.M1 46 47 + ''${blood-elf-0} ${endianFlag} ${bloodFlag} -f ${name}.M1 -o ${name}-footer.M1 48 49 + ''${M1} --architecture ${m2libcArch} \ 50 + ${endianFlag} \ 51 + -f ''${m2libc}/${m2libcArch}/${m2libcArch}_defs.M1 \ 52 + -f ''${m2libc}/${m2libcArch}/libc-full.M1 \ 53 -f ${name}.M1 \ 54 -f ${name}-footer.M1 \ 55 -o ${name}.hex2 56 57 + ''${hex2} --architecture ${m2libcArch} \ 58 + ${endianFlag} \ 59 + -f ''${m2libc}/${m2libcArch}/ELF-${m2libcArch}-debug.hex2 \ 60 -f ${name}.hex2 \ 61 + --base-address ${baseAddress} \ 62 -o ''${out} 63 '') 64 ]; 65 + inherit version M1 M2 blood-elf-0 hex2 m2libc src; 66 }; 67 mkdir = buildMesccToolsExtraUtil "mkdir"; 68 cp = buildMesccToolsExtraUtil "cp"; ··· 78 "--file" 79 ./build.kaem 80 ]; 81 + inherit version M1 M2 blood-elf-0 hex2 mkdir cp chmod replace m2libc src m2libcArch baseAddress bloodFlag endianFlag; 82 83 meta = with lib; { 84 description = "Collection of tools written for use in bootstrapping"; 85 homepage = "https://github.com/oriansj/mescc-tools"; 86 license = licenses.gpl3Plus; 87 maintainers = teams.minimal-bootstrap.members; 88 + inherit platforms; 89 }; 90 }
+29
pkgs/os-specific/linux/minimal-bootstrap/stage0-posix/platforms.nix
···
··· 1 + # Platform specific constants 2 + { lib 3 + , hostPlatform 4 + }: 5 + 6 + rec { 7 + # meta.platforms 8 + platforms = [ 9 + "i686-linux" 10 + "x86_64-linux" 11 + ]; 12 + 13 + # system arch as used within the stage0 project 14 + stage0Arch = { 15 + "i686-linux" = "x86"; 16 + "x86_64-linux" = "AMD64"; 17 + }.${hostPlatform.system} or (throw "Unsupported system: ${hostPlatform.system}"); 18 + 19 + # lower-case form is widely used by m2libc 20 + m2libcArch = lib.toLower stage0Arch; 21 + 22 + # Passed to M2-Mesoplanet as --operating-system 23 + m2libcOS = if hostPlatform.isLinux then "linux" else throw "Unsupported system: ${hostPlatform.system}"; 24 + 25 + baseAddress = { 26 + "i686-linux" = "0x08048000"; 27 + "x86_64-linux" = "0x00600000"; 28 + }.${hostPlatform.system} or (throw "Unsupported system: ${hostPlatform.system}"); 29 + }
+88 -79
pkgs/os-specific/linux/minimal-bootstrap/stage0-posix/stage0-posix-x86.nix pkgs/os-specific/linux/minimal-bootstrap/stage0-posix/mescc-tools-boot.nix
··· 1 - # This is a translation of stage0-posix/stage0-posix/x86/mescc-tools-mini-kaem.kaem to nix 2 - # https://github.com/oriansj/stage0-posix-x86/blob/56e6b8df3e95f4bc04f8b420a4cd8c82c70b9efa/mescc-tools-mini-kaem.kaem 3 - # 4 - # We have access to mini-kaem at this point but it doesn't support substituting 5 - # environment variables. Without variables there's no way of passing in store inputs, 6 - # or the $out path, other than as command line arguments directly 7 - 8 # Mes --- Maxwell Equations of Software 9 # Copyright © 2017,2019 Jan Nieuwenhuizen <janneke@gnu.org> 10 # Copyright © 2017,2019 Jeremiah Orians ··· 24 # You should have received a copy of the GNU General Public License 25 # along with Mes. If not, see <http://www.gnu.org/licenses/>. 26 27 # Warning all binaries prior to the use of blood-elf will not be readable by 28 # Objdump, you may need to use ndism or gdb to view the assembly in the binary. 29 30 { lib 31 , derivationWithMeta 32 , hex0 33 , m2libc 34 , src 35 , version 36 }: 37 rec { 38 out = placeholder "out"; 39 40 run = pname: builder: args: 41 derivationWithMeta { 42 inherit pname version builder args; ··· 46 homepage = "https://github.com/oriansj/stage0-posix"; 47 license = licenses.gpl3Plus; 48 maintainers = teams.minimal-bootstrap.members; 49 - platforms = [ "i686-linux" ]; 50 }; 51 }; 52 ··· 54 # Phase-1 Build hex1 from hex0 # 55 ################################ 56 57 - hex1 = run "hex1" hex0 ["${src}/x86/hex1_x86.hex0" out]; 58 59 # hex1 adds support for single character labels and is available in various forms 60 # in mescc-tools/x86_bootstrap to allow you various ways to verify correctness ··· 63 # Phase-2 Build hex2 from hex1 # 64 ################################ 65 66 - hex2-0 = run "hex2" hex1 ["${src}/x86/hex2_x86.hex1" out]; 67 68 # hex2 adds support for long labels and absolute addresses thus allowing it 69 # to function as an effective linker for later stages of the bootstrap ··· 74 # Phase-2b Build catm from hex2 # 75 ################################# 76 77 - catm = run "catm" hex2-0 ["${src}/x86/catm_x86.hex2" out]; 78 79 # catm removes the need for cat or shell support for redirection by providing 80 # equivalent functionality via catm output_file input1 input2 ... inputN ··· 83 # Phase-3 Build M0 from hex2 # 84 ############################## 85 86 - M0_hex2 = run "M0.hex2" catm [out "${src}/x86/ELF-i386.hex2" "${src}/x86/M0_x86.hex2"]; 87 M0 = run "M0" hex2-0 [M0_hex2 out]; 88 89 # M0 is the architecture specific version of M1 and is by design single 90 # architecture only and will be replaced by the C code version of M1 91 92 ################################ 93 - # Phase-4 Build cc_x86 from M0 # 94 ################################ 95 96 - cc_x86-0_hex2 = run "cc_x86-0.hex2" M0 ["${src}/x86/cc_x86.M1" out]; 97 - cc_x86-1_hex2 = run "cc_x86-1.hex2" catm [out "${src}/x86/ELF-i386.hex2" cc_x86-0_hex2]; 98 - cc_x86 = run "cc_x86" hex2-0 [cc_x86-1_hex2 out]; 99 100 - ####################################### 101 - # Phase-5 Build M2-Planet from cc_x86 # 102 - ####################################### 103 104 M2-0_c = run "M2-0.c" catm [ 105 out 106 - "${m2libc}/x86/linux/bootstrap.c" 107 "${src}/M2-Planet/cc.h" 108 "${m2libc}/bootstrappable.c" 109 "${src}/M2-Planet/cc_globals.c" ··· 114 "${src}/M2-Planet/cc_macro.c" 115 "${src}/M2-Planet/cc.c" 116 ]; 117 - M2-0_M1 = run "M2-0.M1" cc_x86 [M2-0_c out]; 118 - M2-0-0_M1 = run "M2-0-0.M1" catm [out "${src}/x86/x86_defs.M1" "${src}/x86/libc-core.M1" M2-0_M1]; 119 M2-0_hex2 = run "M2-0.hex2" M0 [M2-0-0_M1 out]; 120 - M2-0-0_hex2 = run "M2-0-0.hex2" catm [out "${src}/x86/ELF-i386.hex2" M2-0_hex2]; 121 M2 = run "M2" hex2-0 [M2-0-0_hex2 out]; 122 123 ############################################ ··· 125 ############################################ 126 127 blood-elf-0_M1 = run "blood-elf-0.M1" M2 [ 128 - "--architecture" "x86" 129 - "-f" "${m2libc}/x86/linux/bootstrap.c" 130 "-f" "${m2libc}/bootstrappable.c" 131 "-f" "${src}/mescc-tools/stringify.c" 132 "-f" "${src}/mescc-tools/blood-elf.c" ··· 134 "-o" out 135 ]; 136 137 - blood-elf-0-0_M1 = run "blood-elf-0-0.M1" catm [out "${m2libc}/x86/x86_defs.M1" "${m2libc}/x86/libc-core.M1" blood-elf-0_M1]; 138 blood-elf-0_hex2 = run "blood-elf-0.hex2" M0 [blood-elf-0-0_M1 out]; 139 - blood-elf-0-0_hex2 = run "blood-elf-0-0.hex2" catm [out "${m2libc}/x86/ELF-x86.hex2" blood-elf-0_hex2]; 140 blood-elf-0 = run "blood-elf-0" hex2-0 [blood-elf-0-0_hex2 out]; 141 142 # This is the last stage where the binaries will not have debug info ··· 147 ##################################### 148 149 M1-macro-0_M1 = run "M1-macro-0.M1" M2 [ 150 - "--architecture" "x86" 151 - "-f" "${m2libc}/x86/linux/bootstrap.c" 152 "-f" "${m2libc}/bootstrappable.c" 153 "-f" "${src}/mescc-tools/stringify.c" 154 "-f" "${src}/mescc-tools/M1-macro.c" ··· 157 "-o" out 158 ]; 159 160 - M1-macro-0-footer_M1 = run "M1-macro-0-footer.M1" blood-elf-0 ["-f" M1-macro-0_M1 "--little-endian" "-o" out]; 161 - M1-macro-0-0_M1 = run "M1-macro-0-0.M1" catm [out "${m2libc}/x86/x86_defs.M1" "${m2libc}/x86/libc-core.M1" M1-macro-0_M1 M1-macro-0-footer_M1]; 162 M1-macro-0_hex2 = run "M1-macro-0.hex2" M0 [M1-macro-0-0_M1 out]; 163 - M1-macro-0-0_hex2 = run "M1-macro-0-0.hex2" catm [out "${m2libc}/x86/ELF-x86-debug.hex2" M1-macro-0_hex2]; 164 M1-0 = run "M1-0" hex2-0 [M1-macro-0-0_hex2 out]; 165 166 # This is the last stage where catm will need to be used and the last stage where ··· 172 ####################################### 173 174 hex2_linker-0_M1 = run "hex2_linker-0.M1" M2 [ 175 - "--architecture" "x86" 176 "-f" "${m2libc}/sys/types.h" 177 "-f" "${m2libc}/stddef.h" 178 - "-f" "${m2libc}/x86/linux/unistd.c" 179 - "-f" "${m2libc}/x86/linux/fcntl.c" 180 "-f" "${m2libc}/fcntl.c" 181 - "-f" "${m2libc}/x86/linux/sys/stat.c" 182 "-f" "${m2libc}/stdlib.c" 183 "-f" "${m2libc}/stdio.h" 184 "-f" "${m2libc}/stdio.c" ··· 191 "-o" out 192 ]; 193 194 - hex2_linker-0-footer_M1 = run "hex2_linker-0-footer.M1" blood-elf-0 ["-f" hex2_linker-0_M1 "--little-endian" "-o" out]; 195 196 hex2_linker-0_hex2 = run "hex2_linker-0.hex2" M1-0 [ 197 - "--architecture" "x86" 198 - "--little-endian" 199 - "-f" "${m2libc}/x86/x86_defs.M1" 200 - "-f" "${m2libc}/x86/libc-full.M1" 201 "-f" hex2_linker-0_M1 202 "-f" hex2_linker-0-footer_M1 203 "-o" out 204 ]; 205 206 - hex2_linker-0-0_hex2 = run "hex2_linker-0-0.hex2" catm [out "${m2libc}/x86/ELF-x86-debug.hex2" hex2_linker-0_hex2]; 207 208 hex2-1 = run "hex2-1" hex2-0 [hex2_linker-0-0_hex2 out]; 209 ··· 215 ################################### 216 217 M1-macro-1_M1 = run "M1-macro-1.M1" M2 [ 218 - "--architecture" "x86" 219 "-f" "${m2libc}/sys/types.h" 220 "-f" "${m2libc}/stddef.h" 221 - "-f" "${m2libc}/x86/linux/fcntl.c" 222 "-f" "${m2libc}/fcntl.c" 223 - "-f" "${m2libc}/x86/linux/unistd.c" 224 "-f" "${m2libc}/string.c" 225 "-f" "${m2libc}/stdlib.c" 226 "-f" "${m2libc}/stdio.h" ··· 232 "-o" out 233 ]; 234 235 - M1-macro-1-footer_M1 = run "M1-macro-1-footer.M1" blood-elf-0 ["-f" M1-macro-1_M1 "--little-endian" "-o" out]; 236 237 M1-macro-1_hex2 = run "M1-macro-1.hex2" M1-0 [ 238 - "--architecture" "x86" 239 - "--little-endian" 240 - "-f" "${m2libc}/x86/x86_defs.M1" 241 - "-f" "${m2libc}/x86/libc-full.M1" 242 "-f" M1-macro-1_M1 243 "-f" M1-macro-1-footer_M1 244 "-o" out 245 ]; 246 247 M1 = run "M1" hex2-1 [ 248 - "--architecture" "x86" 249 - "--little-endian" 250 - "--base-address" "0x8048000" 251 - "-f" "${m2libc}/x86/ELF-x86-debug.hex2" 252 "-f" M1-macro-1_hex2 253 "-o" out 254 ]; ··· 258 ###################################### 259 260 hex2_linker-2_M1 = run "hex2_linker-2.M1" M2 [ 261 - "--architecture" "x86" 262 "-f" "${m2libc}/sys/types.h" 263 "-f" "${m2libc}/stddef.h" 264 - "-f" "${m2libc}/x86/linux/unistd.c" 265 - "-f" "${m2libc}/x86/linux/fcntl.c" 266 "-f" "${m2libc}/fcntl.c" 267 - "-f" "${m2libc}/x86/linux/sys/stat.c" 268 "-f" "${m2libc}/stdlib.c" 269 "-f" "${m2libc}/stdio.h" 270 "-f" "${m2libc}/stdio.c" ··· 277 "-o" out 278 ]; 279 280 - hex2_linker-2-footer_M1 = run "hex2_linker-2-footer.M1" blood-elf-0 ["-f" hex2_linker-2_M1 "--little-endian" "-o" out]; 281 282 hex2_linker-2_hex2 = run "hex2_linker-2.hex2" M1 [ 283 - "--architecture" "x86" 284 - "--little-endian" 285 - "-f" "${m2libc}/x86/x86_defs.M1" 286 - "-f" "${m2libc}/x86/libc-full.M1" 287 "-f" hex2_linker-2_M1 288 "-f" hex2_linker-2-footer_M1 289 "-o" out 290 ]; 291 292 hex2 = run "hex2" hex2-1 [ 293 - "--architecture" "x86" 294 - "--little-endian" 295 - "--base-address" "0x8048000" 296 - "-f" "${m2libc}/x86/ELF-x86-debug.hex2" 297 "-f" hex2_linker-2_hex2 298 "-o" out 299 ]; ··· 303 ###################################### 304 305 kaem_M1 = run "kaem.M1" M2 [ 306 - "--architecture" "x86" 307 "-f" "${m2libc}/sys/types.h" 308 "-f" "${m2libc}/stddef.h" 309 "-f" "${m2libc}/string.c" 310 - "-f" "${m2libc}/x86/linux/unistd.c" 311 - "-f" "${m2libc}/x86/linux/fcntl.c" 312 "-f" "${m2libc}/fcntl.c" 313 "-f" "${m2libc}/stdlib.c" 314 "-f" "${m2libc}/stdio.h" ··· 322 "-o" out 323 ]; 324 325 - kaem-footer_M1 = run "kaem-footer.M1" blood-elf-0 ["-f" kaem_M1 "--little-endian" "-o" out]; 326 327 kaem_hex2 = run "kaem.hex2" M1 [ 328 - "--architecture" "x86" 329 - "--little-endian" 330 - "-f" "${m2libc}/x86/x86_defs.M1" 331 - "-f" "${m2libc}/x86/libc-full.M1" 332 "-f" kaem_M1 333 "-f" kaem-footer_M1 334 "-o" out 335 ]; 336 337 kaem-unwrapped = run "kaem-unwrapped" hex2 [ 338 - "--architecture" "x86" 339 - "--little-endian" 340 - "-f" "${m2libc}/x86/ELF-x86-debug.hex2" 341 "-f" kaem_hex2 342 - "--base-address" "0x8048000" 343 "-o" out 344 ]; 345 }
··· 1 # Mes --- Maxwell Equations of Software 2 # Copyright © 2017,2019 Jan Nieuwenhuizen <janneke@gnu.org> 3 # Copyright © 2017,2019 Jeremiah Orians ··· 17 # You should have received a copy of the GNU General Public License 18 # along with Mes. If not, see <http://www.gnu.org/licenses/>. 19 20 + # This is a translation of stage0-posix/stage0-posix/x86/mescc-tools-mini-kaem.kaem to nix 21 + # https://github.com/oriansj/stage0-posix-x86/blob/56e6b8df3e95f4bc04f8b420a4cd8c82c70b9efa/mescc-tools-mini-kaem.kaem 22 + # 23 + # We have access to mini-kaem at this point but it doesn't support substituting 24 + # environment variables. Without variables there's no way of passing in store inputs, 25 + # or the $out path, other than as command line arguments directly 26 + 27 # Warning all binaries prior to the use of blood-elf will not be readable by 28 # Objdump, you may need to use ndism or gdb to view the assembly in the binary. 29 30 { lib 31 , derivationWithMeta 32 + , hostPlatform 33 , hex0 34 , m2libc 35 , src 36 , version 37 + , platforms 38 + , stage0Arch 39 + , m2libcArch 40 + , baseAddress 41 }: 42 rec { 43 out = placeholder "out"; 44 45 + endianFlag = if hostPlatform.isLittleEndian then "--little-endian" else "--big-endian"; 46 + 47 + bloodFlags = lib.optional hostPlatform.is64bit "--64"; 48 + 49 run = pname: builder: args: 50 derivationWithMeta { 51 inherit pname version builder args; ··· 55 homepage = "https://github.com/oriansj/stage0-posix"; 56 license = licenses.gpl3Plus; 57 maintainers = teams.minimal-bootstrap.members; 58 + inherit platforms; 59 }; 60 }; 61 ··· 63 # Phase-1 Build hex1 from hex0 # 64 ################################ 65 66 + hex1 = run "hex1" hex0 ["${src}/${stage0Arch}/hex1_${stage0Arch}.hex0" out]; 67 68 # hex1 adds support for single character labels and is available in various forms 69 # in mescc-tools/x86_bootstrap to allow you various ways to verify correctness ··· 72 # Phase-2 Build hex2 from hex1 # 73 ################################ 74 75 + hex2-0 = run "hex2" hex1 ["${src}/${stage0Arch}/hex2_${stage0Arch}.hex1" out]; 76 77 # hex2 adds support for long labels and absolute addresses thus allowing it 78 # to function as an effective linker for later stages of the bootstrap ··· 83 # Phase-2b Build catm from hex2 # 84 ################################# 85 86 + catm = run "catm" hex2-0 ["${src}/${stage0Arch}/catm_${stage0Arch}.hex2" out]; 87 88 # catm removes the need for cat or shell support for redirection by providing 89 # equivalent functionality via catm output_file input1 input2 ... inputN ··· 92 # Phase-3 Build M0 from hex2 # 93 ############################## 94 95 + M0_hex2 = run "M0.hex2" catm [out "${m2libc}/${m2libcArch}/ELF-${m2libcArch}.hex2" "${src}/${stage0Arch}/M0_${stage0Arch}.hex2"]; 96 M0 = run "M0" hex2-0 [M0_hex2 out]; 97 98 # M0 is the architecture specific version of M1 and is by design single 99 # architecture only and will be replaced by the C code version of M1 100 101 ################################ 102 + # Phase-4 Build cc_arch from M0 # 103 ################################ 104 105 + cc_arch-0_hex2 = run "cc_arch-0.hex2" M0 ["${src}/${stage0Arch}/cc_${m2libcArch}.M1" out]; 106 + cc_arch-1_hex2 = run "cc_arch-1.hex2" catm [out "${m2libc}/${m2libcArch}/ELF-${m2libcArch}.hex2" cc_arch-0_hex2]; 107 + cc_arch = run "cc_arch" hex2-0 [cc_arch-1_hex2 out]; 108 109 + ######################################## 110 + # Phase-5 Build M2-Planet from cc_arch # 111 + ######################################## 112 113 M2-0_c = run "M2-0.c" catm [ 114 out 115 + "${m2libc}/${m2libcArch}/linux/bootstrap.c" 116 "${src}/M2-Planet/cc.h" 117 "${m2libc}/bootstrappable.c" 118 "${src}/M2-Planet/cc_globals.c" ··· 123 "${src}/M2-Planet/cc_macro.c" 124 "${src}/M2-Planet/cc.c" 125 ]; 126 + M2-0_M1 = run "M2-0.M1" cc_arch [M2-0_c out]; 127 + M2-0-0_M1 = run "M2-0-0.M1" catm [out "${m2libc}/${m2libcArch}/${m2libcArch}_defs.M1" "${m2libc}/${m2libcArch}/libc-core.M1" M2-0_M1]; 128 M2-0_hex2 = run "M2-0.hex2" M0 [M2-0-0_M1 out]; 129 + M2-0-0_hex2 = run "M2-0-0.hex2" catm [out "${m2libc}/${m2libcArch}/ELF-${m2libcArch}.hex2" M2-0_hex2]; 130 M2 = run "M2" hex2-0 [M2-0-0_hex2 out]; 131 132 ############################################ ··· 134 ############################################ 135 136 blood-elf-0_M1 = run "blood-elf-0.M1" M2 [ 137 + "--architecture" m2libcArch 138 + "-f" "${m2libc}/${m2libcArch}/linux/bootstrap.c" 139 "-f" "${m2libc}/bootstrappable.c" 140 "-f" "${src}/mescc-tools/stringify.c" 141 "-f" "${src}/mescc-tools/blood-elf.c" ··· 143 "-o" out 144 ]; 145 146 + blood-elf-0-0_M1 = run "blood-elf-0-0.M1" catm [out "${m2libc}/${m2libcArch}/${m2libcArch}_defs.M1" "${m2libc}/${m2libcArch}/libc-core.M1" blood-elf-0_M1]; 147 blood-elf-0_hex2 = run "blood-elf-0.hex2" M0 [blood-elf-0-0_M1 out]; 148 + blood-elf-0-0_hex2 = run "blood-elf-0-0.hex2" catm [out "${m2libc}/${m2libcArch}/ELF-${m2libcArch}.hex2" blood-elf-0_hex2]; 149 blood-elf-0 = run "blood-elf-0" hex2-0 [blood-elf-0-0_hex2 out]; 150 151 # This is the last stage where the binaries will not have debug info ··· 156 ##################################### 157 158 M1-macro-0_M1 = run "M1-macro-0.M1" M2 [ 159 + "--architecture" m2libcArch 160 + "-f" "${m2libc}/${m2libcArch}/linux/bootstrap.c" 161 "-f" "${m2libc}/bootstrappable.c" 162 "-f" "${src}/mescc-tools/stringify.c" 163 "-f" "${src}/mescc-tools/M1-macro.c" ··· 166 "-o" out 167 ]; 168 169 + M1-macro-0-footer_M1 = run "M1-macro-0-footer.M1" blood-elf-0 (bloodFlags ++ ["-f" M1-macro-0_M1 endianFlag "-o" out]); 170 + M1-macro-0-0_M1 = run "M1-macro-0-0.M1" catm [out "${m2libc}/${m2libcArch}/${m2libcArch}_defs.M1" "${m2libc}/${m2libcArch}/libc-core.M1" M1-macro-0_M1 M1-macro-0-footer_M1]; 171 M1-macro-0_hex2 = run "M1-macro-0.hex2" M0 [M1-macro-0-0_M1 out]; 172 + M1-macro-0-0_hex2 = run "M1-macro-0-0.hex2" catm [out "${m2libc}/${m2libcArch}/ELF-${m2libcArch}-debug.hex2" M1-macro-0_hex2]; 173 M1-0 = run "M1-0" hex2-0 [M1-macro-0-0_hex2 out]; 174 175 # This is the last stage where catm will need to be used and the last stage where ··· 181 ####################################### 182 183 hex2_linker-0_M1 = run "hex2_linker-0.M1" M2 [ 184 + "--architecture" m2libcArch 185 "-f" "${m2libc}/sys/types.h" 186 "-f" "${m2libc}/stddef.h" 187 + "-f" "${m2libc}/${m2libcArch}/linux/unistd.c" 188 + "-f" "${m2libc}/${m2libcArch}/linux/fcntl.c" 189 "-f" "${m2libc}/fcntl.c" 190 + "-f" "${m2libc}/${m2libcArch}/linux/sys/stat.c" 191 "-f" "${m2libc}/stdlib.c" 192 "-f" "${m2libc}/stdio.h" 193 "-f" "${m2libc}/stdio.c" ··· 200 "-o" out 201 ]; 202 203 + hex2_linker-0-footer_M1 = run "hex2_linker-0-footer.M1" blood-elf-0 (bloodFlags ++ ["-f" hex2_linker-0_M1 endianFlag "-o" out]); 204 205 hex2_linker-0_hex2 = run "hex2_linker-0.hex2" M1-0 [ 206 + "--architecture" m2libcArch 207 + endianFlag 208 + "-f" "${m2libc}/${m2libcArch}/${m2libcArch}_defs.M1" 209 + "-f" "${m2libc}/${m2libcArch}/libc-full.M1" 210 "-f" hex2_linker-0_M1 211 "-f" hex2_linker-0-footer_M1 212 "-o" out 213 ]; 214 215 + hex2_linker-0-0_hex2 = run "hex2_linker-0-0.hex2" catm [out "${m2libc}/${m2libcArch}/ELF-${m2libcArch}-debug.hex2" hex2_linker-0_hex2]; 216 217 hex2-1 = run "hex2-1" hex2-0 [hex2_linker-0-0_hex2 out]; 218 ··· 224 ################################### 225 226 M1-macro-1_M1 = run "M1-macro-1.M1" M2 [ 227 + "--architecture" m2libcArch 228 "-f" "${m2libc}/sys/types.h" 229 "-f" "${m2libc}/stddef.h" 230 + "-f" "${m2libc}/${m2libcArch}/linux/fcntl.c" 231 "-f" "${m2libc}/fcntl.c" 232 + "-f" "${m2libc}/${m2libcArch}/linux/unistd.c" 233 "-f" "${m2libc}/string.c" 234 "-f" "${m2libc}/stdlib.c" 235 "-f" "${m2libc}/stdio.h" ··· 241 "-o" out 242 ]; 243 244 + M1-macro-1-footer_M1 = run "M1-macro-1-footer.M1" blood-elf-0 (bloodFlags ++ ["-f" M1-macro-1_M1 endianFlag "-o" out]); 245 246 M1-macro-1_hex2 = run "M1-macro-1.hex2" M1-0 [ 247 + "--architecture" m2libcArch 248 + endianFlag 249 + "-f" "${m2libc}/${m2libcArch}/${m2libcArch}_defs.M1" 250 + "-f" "${m2libc}/${m2libcArch}/libc-full.M1" 251 "-f" M1-macro-1_M1 252 "-f" M1-macro-1-footer_M1 253 "-o" out 254 ]; 255 256 M1 = run "M1" hex2-1 [ 257 + "--architecture" m2libcArch 258 + endianFlag 259 + "--base-address" baseAddress 260 + "-f" "${m2libc}/${m2libcArch}/ELF-${m2libcArch}-debug.hex2" 261 "-f" M1-macro-1_hex2 262 "-o" out 263 ]; ··· 267 ###################################### 268 269 hex2_linker-2_M1 = run "hex2_linker-2.M1" M2 [ 270 + "--architecture" m2libcArch 271 "-f" "${m2libc}/sys/types.h" 272 "-f" "${m2libc}/stddef.h" 273 + "-f" "${m2libc}/${m2libcArch}/linux/unistd.c" 274 + "-f" "${m2libc}/${m2libcArch}/linux/fcntl.c" 275 "-f" "${m2libc}/fcntl.c" 276 + "-f" "${m2libc}/${m2libcArch}/linux/sys/stat.c" 277 "-f" "${m2libc}/stdlib.c" 278 "-f" "${m2libc}/stdio.h" 279 "-f" "${m2libc}/stdio.c" ··· 286 "-o" out 287 ]; 288 289 + hex2_linker-2-footer_M1 = run "hex2_linker-2-footer.M1" blood-elf-0 (bloodFlags ++ ["-f" hex2_linker-2_M1 endianFlag "-o" out]); 290 291 hex2_linker-2_hex2 = run "hex2_linker-2.hex2" M1 [ 292 + "--architecture" m2libcArch 293 + endianFlag 294 + "-f" "${m2libc}/${m2libcArch}/${m2libcArch}_defs.M1" 295 + "-f" "${m2libc}/${m2libcArch}/libc-full.M1" 296 "-f" hex2_linker-2_M1 297 "-f" hex2_linker-2-footer_M1 298 "-o" out 299 ]; 300 301 hex2 = run "hex2" hex2-1 [ 302 + "--architecture" m2libcArch 303 + endianFlag 304 + "--base-address" baseAddress 305 + "-f" "${m2libc}/${m2libcArch}/ELF-${m2libcArch}-debug.hex2" 306 "-f" hex2_linker-2_hex2 307 "-o" out 308 ]; ··· 312 ###################################### 313 314 kaem_M1 = run "kaem.M1" M2 [ 315 + "--architecture" m2libcArch 316 "-f" "${m2libc}/sys/types.h" 317 "-f" "${m2libc}/stddef.h" 318 "-f" "${m2libc}/string.c" 319 + "-f" "${m2libc}/${m2libcArch}/linux/unistd.c" 320 + "-f" "${m2libc}/${m2libcArch}/linux/fcntl.c" 321 "-f" "${m2libc}/fcntl.c" 322 "-f" "${m2libc}/stdlib.c" 323 "-f" "${m2libc}/stdio.h" ··· 331 "-o" out 332 ]; 333 334 + kaem-footer_M1 = run "kaem-footer.M1" blood-elf-0 (bloodFlags ++ ["-f" kaem_M1 endianFlag "-o" out]); 335 336 kaem_hex2 = run "kaem.hex2" M1 [ 337 + "--architecture" m2libcArch 338 + endianFlag 339 + "-f" "${m2libc}/${m2libcArch}/${m2libcArch}_defs.M1" 340 + "-f" "${m2libc}/${m2libcArch}/libc-full.M1" 341 "-f" kaem_M1 342 "-f" kaem-footer_M1 343 "-o" out 344 ]; 345 346 kaem-unwrapped = run "kaem-unwrapped" hex2 [ 347 + "--architecture" m2libcArch 348 + endianFlag 349 + "-f" "${m2libc}/${m2libcArch}/ELF-${m2libcArch}-debug.hex2" 350 "-f" kaem_hex2 351 + "--base-address" baseAddress 352 "-o" out 353 ]; 354 }