# --- T2-COPYRIGHT-NOTE-BEGIN --- # This copyright note is auto-generated by scripts/Create-CopyPatch. # # T2 SDE: package/.../arcload/elf32-netboot.patch # Copyright (C) 2020 The T2 SDE Project # # More information can be found in the files COPYING and README. # # This patch file is dual-licensed. It is available under the license the # patched project is licensed under, as long as it is an OpenSource license # as defined at http://www.opensource.org/ (e.g. BSD, X11) or under the terms # of the GNU General Public License as published by the Free Software # Foundation; either version 2 of the License, or (at your option) any later # version. # --- T2-COPYRIGHT-NOTE-END --- Fix loading 32-bit kernel on 32-bit Arcs over bootp / tftp on earlier Sgi machines, like the precious and famous O2. Signed-off-by: René Rebe --- arcload-0.5-patched/loader/main.c.vanilla 2020-08-28 21:38:30.189076493 +0200 +++ arcload-0.5-patched/loader/main.c 2020-08-30 14:42:32.672622589 +0200 @@ -325,7 +325,7 @@ printf("Loading %s...\n\r", fname); /* Read ELF Header */ - if(bread(&file, sizeof(hdr), &hdr)<0) { + if(bread(&file, sizeof(hdr.e_ident), &hdr)<0) { printf("Error reading ELF header.\n\r"); goto close; } @@ -346,6 +346,14 @@ goto close; } + /* read the rest of the header */ + if(bread(&file, (hdr.e_ident[EI_CLASS] == ELFCLASS64 ? + sizeof(Elf64_Ehdr) : sizeof(Elf32_Ehdr)) - EI_NIDENT, + &hdr.e_ident[EI_NIDENT]) < 0) { + printf("Error reading remaining ELF header.\n\r"); + return 0; + } + /* 32 or 64 bit? */ if(hdr.e_ident[EI_CLASS] == ELFCLASS64) { kentry = load_elf64(&hdr.e64, &file);