Module Name: src
Committed By: nonaka
Date: Thu Feb 23 12:13:05 UTC 2017
Modified Files:
src/sys/lib/libsa: loadfile_elf32.c
Log Message:
fix CTF section symbol size was not counted with COUNT_KERNEL.
To generate a diff of this commit:
cvs rdiff -u -r1.34 -r1.35 src/sys/lib/libsa/loadfile_elf32.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/lib/libsa/loadfile_elf32.c
diff -u src/sys/lib/libsa/loadfile_elf32.c:1.34 src/sys/lib/libsa/loadfile_elf32.c:1.35
--- src/sys/lib/libsa/loadfile_elf32.c:1.34 Fri Jan 6 09:14:36 2017
+++ src/sys/lib/libsa/loadfile_elf32.c Thu Feb 23 12:13:05 2017
@@ -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.
@@ -428,41 +428,37 @@ ELFNAMEEND(loadfile)(int fd, Elf_Ehdr *e
* First load the section names section.
*/
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 (lseek(fd, shp[elf->e_shstrndx].sh_offset,
- SEEK_SET) == -1) {
+ if (lseek(fd, shstroff, SEEK_SET) == -1) {
WARN(("lseek symbols"));
goto freeshp;
}
- nr = READ(fd, maxp,
- shp[elf->e_shstrndx].sh_size);
+ nr = READ(fd, maxp, shstrsz);
if (nr == -1) {
WARN(("read symbols"));
goto freeshp;
}
- if (nr !=
- (ssize_t)shp[elf->e_shstrndx].sh_size) {
+ if (nr != (ssize_t)shstrsz) {
errno = EIO;
WARN(("read symbols"));
goto freeshp;
}
+ }
- shstr = ALLOC(shp[elf->e_shstrndx].sh_size);
- shstrsz = shp[elf->e_shstrndx].sh_size;
- if (lseek(fd, shp[elf->e_shstrndx].sh_offset,
- SEEK_SET) == -1) {
- WARN(("lseek symbols"));
- goto freeshp;
- }
- nr = read(fd, shstr,
- shp[elf->e_shstrndx].sh_size);
- if (nr == -1) {
- WARN(("read symbols"));
- goto freeshp;
- }
+ shstr = ALLOC(shstrsz);
+ if (lseek(fd, shstroff, SEEK_SET) == -1) {
+ WARN(("lseek symbols"));
+ goto freeshp;
+ }
+ nr = read(fd, shstr, shstrsz);
+ if (nr == -1) {
+ WARN(("read symbols"));
+ goto freeshp;
}
shp[elf->e_shstrndx].sh_offset = maxp - elfp;
- maxp += roundup(shp[elf->e_shstrndx].sh_size, ELFROUND);
+ maxp += roundup(shstrsz, ELFROUND);
}
/*