diff --git a/lib/libkldelf/ef_obj.c b/lib/libkldelf/ef_obj.c --- a/lib/libkldelf/ef_obj.c +++ b/lib/libkldelf/ef_obj.c @@ -304,9 +304,13 @@ symtabindex = -1; symstrindex = -1; for (i = 0; i < nshdr; i++) { + if (shdr[i].sh_size == 0) + continue; switch (shdr[i].sh_type) { case SHT_PROGBITS: case SHT_NOBITS: + if ((shdr[i].sh_flags & SHF_ALLOC) == 0) + break; ef->nprogtab++; break; case SHT_SYMTAB: @@ -385,9 +389,13 @@ ra = 0; mapbase = 0; for (i = 0; i < nshdr; i++) { + if (shdr[i].sh_size == 0) + continue; switch (shdr[i].sh_type) { case SHT_PROGBITS: case SHT_NOBITS: + if ((shdr[i].sh_flags & SHF_ALLOC) == 0) + break; mapbase = roundup2(mapbase, shdr[i].sh_addralign); ef->progtab[pb].addr = mapbase; if (shdr[i].sh_type == SHT_PROGBITS) {