Skip to content

Commit

Permalink
Merge pull request #193 from flaviojs/clear-uninitilized-sections-ppc…
Browse files Browse the repository at this point in the history
…32_load_elf_image

Clear uninitialized sections in ppc32_load_elf_image.
  • Loading branch information
grossmj authored Mar 27, 2024
2 parents 9fb94e5 + 7dbdcb7 commit c2fdb8c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 10 deletions.
15 changes: 10 additions & 5 deletions stable/ppc32.c
Original file line number Diff line number Diff line change
Expand Up @@ -639,11 +639,16 @@ int ppc32_load_elf_image(cpu_ppc_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;
Expand Down
15 changes: 10 additions & 5 deletions unstable/ppc32.c
Original file line number Diff line number Diff line change
Expand Up @@ -636,11 +636,16 @@ int ppc32_load_elf_image(cpu_ppc_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;
Expand Down

0 comments on commit c2fdb8c

Please sign in to comment.