Loader uses ElfLoader::memorySize to determine the number of tagged
pages to allocate, as some of those pages are only partially filled (e.g. last page of loadable segment) we may allocate too few tagged pages and boot will fail. So lie by reporting extra size for each partial tagged page. XXX: This is an ugly hack, but I'm not going to shave this yak.
This commit is contained in:
parent
61e8b62888
commit
de58f0245a
@ -1,4 +1,4 @@
|
|||||||
/* $NetBSD: load_elf.cpp,v 1.16 2006/03/02 23:56:58 uwe Exp $ */
|
/* $NetBSD: load_elf.cpp,v 1.17 2006/03/05 04:04:13 uwe Exp $ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 2001 The NetBSD Foundation, Inc.
|
* Copyright (c) 2001 The NetBSD Foundation, Inc.
|
||||||
@ -111,6 +111,7 @@ ElfLoader::memorySize()
|
|||||||
int i;
|
int i;
|
||||||
Elf_Phdr *ph = _ph;
|
Elf_Phdr *ph = _ph;
|
||||||
size_t sz = 0;
|
size_t sz = 0;
|
||||||
|
size_t extra = 0;
|
||||||
|
|
||||||
DPRINTF((TEXT("file size: ")));
|
DPRINTF((TEXT("file size: ")));
|
||||||
for (i = 0; i < _eh.e_phnum; i++, ph++) {
|
for (i = 0; i < _eh.e_phnum; i++, ph++) {
|
||||||
@ -120,6 +121,12 @@ ElfLoader::memorySize()
|
|||||||
sz == 0 ? "" : "+",
|
sz == 0 ? "" : "+",
|
||||||
filesz));
|
filesz));
|
||||||
sz += _mem->roundPage(filesz);
|
sz += _mem->roundPage(filesz);
|
||||||
|
// compensate for partial last tag
|
||||||
|
extra += _mem->getTaggedPageSize();
|
||||||
|
if (filesz < ph->p_memsz)
|
||||||
|
// compensate for zero clear
|
||||||
|
extra += _mem->getTaggedPageSize();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -128,8 +135,13 @@ ElfLoader::memorySize()
|
|||||||
if (symblk_sz) {
|
if (symblk_sz) {
|
||||||
sz += symblk_sz;
|
sz += symblk_sz;
|
||||||
DPRINTF((TEXT(" = 0x%x]"), symblk_sz));
|
DPRINTF((TEXT(" = 0x%x]"), symblk_sz));
|
||||||
|
// XXX: compensate for partial tags after ELF header and symtab
|
||||||
|
extra += 2 * _mem->getTaggedPageSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sz += extra;
|
||||||
|
DPRINTF((TEXT("+[extra: 0x%x]"), extra));
|
||||||
|
|
||||||
DPRINTF((TEXT(" = 0x%x bytes\n"), sz));
|
DPRINTF((TEXT(" = 0x%x bytes\n"), sz));
|
||||||
return sz;
|
return sz;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user