2012-01-04 Mark Hatle * exec.c: Check that a section is larger then 0 bytes when determining the section to segment mapping. This matches the behavior of elfutils - readelf. Otherwise an empty PROGBITS section at the end of a segment will cause a failure. diff --git a/trunk/src/exec.c b/trunk/src/exec.c index 7c8f38f..cf38b72 100644 --- a/trunk/src/exec.c +++ b/trunk/src/exec.c @@ -500,7 +500,8 @@ error_out: int sfirst = 0, slast = 0, last = 0; for (j = 1; j < dso->ehdr.e_shnum; ++j) - if (dso->shdr[j].sh_addr >= dso->phdr[i].p_vaddr + if (dso->shdr[j].sh_size > 0 + && dso->shdr[j].sh_addr >= dso->phdr[i].p_vaddr && dso->shdr[j].sh_addr + dso->shdr[j].sh_size <= dso->phdr[i].p_vaddr + dso->phdr[i].p_memsz) { @@ -572,7 +573,8 @@ error_out: } for (j = 1; j < dso->ehdr.e_shnum; ++j) - if (dso->shdr[j].sh_addr >= dso->phdr[i].p_vaddr + if (dso->shdr[j].sh_size > 0 + && dso->shdr[j].sh_addr >= dso->phdr[i].p_vaddr && dso->shdr[j].sh_addr + dso->shdr[j].sh_size <= dso->phdr[i].p_vaddr + dso->phdr[i].p_memsz) {