Index: head/stand/common/load_elf_obj.c =================================================================== --- head/stand/common/load_elf_obj.c +++ head/stand/common/load_elf_obj.c @@ -224,6 +224,8 @@ #if defined(__i386__) || defined(__amd64__) case SHT_X86_64_UNWIND: #endif + if ((shdr[i].sh_flags & SHF_ALLOC) == 0) + break; lastaddr = roundup(lastaddr, shdr[i].sh_addralign); shdr[i].sh_addr = (Elf_Addr)lastaddr; lastaddr += shdr[i].sh_size; Index: head/sys/kern/link_elf_obj.c =================================================================== --- head/sys/kern/link_elf_obj.c +++ head/sys/kern/link_elf_obj.c @@ -262,6 +262,9 @@ #ifdef __amd64__ case SHT_X86_64_UNWIND: #endif + /* Ignore sections not loaded by the loader. */ + if (shdr[i].sh_addr == 0) + break; ef->nprogtab++; break; case SHT_SYMTAB: @@ -335,6 +338,8 @@ #ifdef __amd64__ case SHT_X86_64_UNWIND: #endif + if (shdr[i].sh_addr == 0) + break; ef->progtab[pb].addr = (void *)shdr[i].sh_addr; if (shdr[i].sh_type == SHT_PROGBITS) ef->progtab[pb].name = "<>"; @@ -605,6 +610,8 @@ #ifdef __amd64__ case SHT_X86_64_UNWIND: #endif + if ((shdr[i].sh_flags & SHF_ALLOC) == 0) + break; ef->nprogtab++; break; case SHT_SYMTAB: @@ -720,6 +727,8 @@ #ifdef __amd64__ case SHT_X86_64_UNWIND: #endif + if ((shdr[i].sh_flags & SHF_ALLOC) == 0) + break; alignmask = shdr[i].sh_addralign - 1; mapsize += alignmask; mapsize &= ~alignmask; @@ -790,6 +799,8 @@ #ifdef __amd64__ case SHT_X86_64_UNWIND: #endif + if ((shdr[i].sh_flags & SHF_ALLOC) == 0) + break; alignmask = shdr[i].sh_addralign - 1; mapbase += alignmask; mapbase &= ~alignmask;