fix CTF section symbol size was not counted with COUNT_KERNEL.

This commit is contained in:
nonaka 2017-02-23 12:13:05 +00:00
parent 3745de3e82
commit 3f166eb124
1 changed files with 17 additions and 21 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: loadfile_elf32.c,v 1.34 2017/01/06 09:14:36 maxv Exp $ */ /* $NetBSD: loadfile_elf32.c,v 1.35 2017/02/23 12:13:05 nonaka Exp $ */
/* /*
* Copyright (c) 1997, 2008 The NetBSD Foundation, Inc. * Copyright (c) 1997, 2008 The NetBSD Foundation, Inc.
@ -428,41 +428,37 @@ ELFNAMEEND(loadfile)(int fd, Elf_Ehdr *elf, u_long *marks, int flags)
* First load the section names section. * First load the section names section.
*/ */
if (boot_load_ctf && (elf->e_shstrndx != 0)) { if (boot_load_ctf && (elf->e_shstrndx != 0)) {
Elf_Off shstroff = shp[elf->e_shstrndx].sh_offset;
shstrsz = shp[elf->e_shstrndx].sh_size;
if (flags & LOAD_SYM) { if (flags & LOAD_SYM) {
if (lseek(fd, shp[elf->e_shstrndx].sh_offset, if (lseek(fd, shstroff, SEEK_SET) == -1) {
SEEK_SET) == -1) {
WARN(("lseek symbols")); WARN(("lseek symbols"));
goto freeshp; goto freeshp;
} }
nr = READ(fd, maxp, nr = READ(fd, maxp, shstrsz);
shp[elf->e_shstrndx].sh_size);
if (nr == -1) { if (nr == -1) {
WARN(("read symbols")); WARN(("read symbols"));
goto freeshp; goto freeshp;
} }
if (nr != if (nr != (ssize_t)shstrsz) {
(ssize_t)shp[elf->e_shstrndx].sh_size) {
errno = EIO; errno = EIO;
WARN(("read symbols")); WARN(("read symbols"));
goto freeshp; goto freeshp;
} }
}
shstr = ALLOC(shp[elf->e_shstrndx].sh_size); shstr = ALLOC(shstrsz);
shstrsz = shp[elf->e_shstrndx].sh_size; if (lseek(fd, shstroff, SEEK_SET) == -1) {
if (lseek(fd, shp[elf->e_shstrndx].sh_offset, WARN(("lseek symbols"));
SEEK_SET) == -1) { goto freeshp;
WARN(("lseek symbols")); }
goto freeshp; nr = read(fd, shstr, shstrsz);
} if (nr == -1) {
nr = read(fd, shstr, WARN(("read symbols"));
shp[elf->e_shstrndx].sh_size); goto freeshp;
if (nr == -1) {
WARN(("read symbols"));
goto freeshp;
}
} }
shp[elf->e_shstrndx].sh_offset = maxp - elfp; shp[elf->e_shstrndx].sh_offset = maxp - elfp;
maxp += roundup(shp[elf->e_shstrndx].sh_size, ELFROUND); maxp += roundup(shstrsz, ELFROUND);
} }
/* /*