From Nigel Pearson: Make SYMS and NSYMS work on ELF.

The MacOS booter needs them.
This commit is contained in:
christos 2001-07-13 17:17:12 +00:00
parent 5f1585220e
commit 6711e49228

View File

@ -1,4 +1,4 @@
/* $NetBSD: loadfile.c,v 1.10 2000/12/03 02:53:04 tsutsui Exp $ */
/* $NetBSD: loadfile.c,v 1.11 2001/07/13 17:17:12 christos Exp $ */
/*-
* Copyright (c) 1997 The NetBSD Foundation, Inc.
@ -277,8 +277,8 @@ elf_exec(fd, elf, marks, flags)
int i;
size_t sz;
int first;
int havesyms;
paddr_t minp = ~0, maxp = 0, pos;
int havesyms, numsyms;
paddr_t minp = ~0, maxp = 0, pos, symp;
paddr_t offset = marks[MARK_START], shpp, elfp;
for (first = 1, i = 0; i < elf->e_phnum; i++) {
@ -383,6 +383,14 @@ elf_exec(fd, elf, marks, flags)
havesyms = 1;
for (first = 1, i = 0; i < elf->e_shnum; i++) {
if (shp[i].sh_type == SHT_SYMTAB) {
if (symp == NULL) {
/* Save addr of first sym section */
symp = maxp;
}
numsyms += roundup(shp[i].sh_size,
sizeof(long));
}
if (shp[i].sh_type == SHT_SYMTAB ||
shp[i].sh_type == SHT_STRTAB) {
if (havesyms && (flags & LOAD_SYM)) {
@ -431,8 +439,11 @@ elf_exec(fd, elf, marks, flags)
marks[MARK_START] = LOADADDR(minp);
marks[MARK_ENTRY] = LOADADDR(elf->e_entry);
marks[MARK_NSYM] = 1; /* XXX: Kernel needs >= 0 */
marks[MARK_SYM] = LOADADDR(elfp);
if (!numsyms)
marks[MARK_NSYM] = 1; /* XXX: Kernel needs >= 0 */
else
marks[MARK_NSYM] = numsyms;
marks[MARK_SYM] = LOADADDR(symp);
marks[MARK_END] = LOADADDR(maxp);
return 0;
}