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,16 @@ 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: + case SHT_X86_64_UNWIND: + case SHT_INIT_ARRAY: + case SHT_FINI_ARRAY: + if ((shdr[i].sh_flags & SHF_ALLOC) == 0) + break; ef->nprogtab++; break; case SHT_SYMTAB: @@ -385,9 +392,16 @@ 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: + case SHT_X86_64_UNWIND: + case SHT_INIT_ARRAY: + case SHT_FINI_ARRAY: + 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) {