diff --git a/stable/mips64.c b/stable/mips64.c index b84e874fd..6278ae329 100644 --- a/stable/mips64.c +++ b/stable/mips64.c @@ -1013,11 +1013,16 @@ int mips64_load_elf_image(cpu_mips_t *cpu,char *filename,int skip_load, clen = m_min(clen,remain); - if (fread((u_char *)haddr,clen,1,bfd) != 1) { - perror("load_elf_image: fread"); - elf_end(img_elf); - fclose(bfd); - return(-1); + if (shdr->sh_type == SHT_NOBITS) { + // section with uninitialized data, zero it + memset((u_char *)haddr, 0, clen); + } else { + if (fread((u_char *)haddr,clen,1,bfd) != 1) { + perror("load_elf_image: fread"); + elf_end(img_elf); + fclose(bfd); + return(-1); + } } vaddr += clen; diff --git a/unstable/mips64.c b/unstable/mips64.c index 66a1174be..445c7fcfa 100644 --- a/unstable/mips64.c +++ b/unstable/mips64.c @@ -1096,11 +1096,16 @@ int mips64_load_elf_image(cpu_mips_t *cpu,char *filename,int skip_load, clen = m_min(clen,remain); - if (fread((u_char *)haddr,clen,1,bfd) != 1) { - perror("load_elf_image: fread"); - elf_end(img_elf); - fclose(bfd); - return(-1); + if (shdr->sh_type == SHT_NOBITS) { + // section with uninitialized data, zero it + memset((u_char *)haddr, 0, clen); + } else { + if (fread((u_char *)haddr,clen,1,bfd) != 1) { + perror("load_elf_image: fread"); + elf_end(img_elf); + fclose(bfd); + return(-1); + } } vaddr += clen;