diff --git a/netdump.c b/netdump.c index abc85e0..0c7cc80 100644 --- a/netdump.c +++ b/netdump.c @@ -608,7 +608,20 @@ read_netdump(int fd, void *bufptr, int cnt, ulong addr, physaddr_t paddr) "offset: %llx\n", (ulonglong)offset); return SEEK_ERROR; } - if (read(nd->ndfd, bufptr, cnt) != cnt) { + /* + * if incomplete flag is set in ELF file, zero will be used to fill + * the lost part. + */ + ssize_t read_ret = read(nd->ndfd, bufptr, cnt); + if (read_ret != cnt) { + unsigned int e_flag = (NULL == nd->elf64) ? + (nd->elf32)->e_flags : (nd->elf64)->e_flags; + int status = e_flag & DUMP_ELF_INCOMPLETE; + if (status && read_ret >= 0) { + bufptr += read_ret; + bzero(bufptr, cnt - read_ret); + return cnt; + } if (CRASHDEBUG(8)) fprintf(fp, "read_netdump: READ_ERROR: " "offset: %llx\n", (ulonglong)offset);