diff options
author | kn <kn@cvs.openbsd.org> | 2020-06-13 12:25:10 +0000 |
---|---|---|
committer | kn <kn@cvs.openbsd.org> | 2020-06-13 12:25:10 +0000 |
commit | 65ffe57824853900af79214a505be49b37746ea3 (patch) | |
tree | ac237c1193c413fd8e3119299f41b816f9a8a4f6 /sys | |
parent | cfd05a8ec98e88bdb035eabb30bd3bf3b061b87a (diff) |
Load CTF section to enable DDB's "show struct"
Other platforms use libsa's ELFNAME(), e.g., elf64_exec() on amd64,
already to load the kernel's ELF section ".SUNW_ctf".
Adapt ofwboot accordingly to enable ddb(4) on sparc64 as well to utilise
CTF information for commands like "show struct".
Hints from mpi
OK kettenis mpi
Diffstat (limited to 'sys')
-rw-r--r-- | sys/arch/sparc64/stand/ofwboot/elf64_exec.c | 21 | ||||
-rw-r--r-- | sys/arch/sparc64/stand/ofwboot/vers.c | 2 |
2 files changed, 19 insertions, 4 deletions
diff --git a/sys/arch/sparc64/stand/ofwboot/elf64_exec.c b/sys/arch/sparc64/stand/ofwboot/elf64_exec.c index 887aa57453d..00417ce7c7b 100644 --- a/sys/arch/sparc64/stand/ofwboot/elf64_exec.c +++ b/sys/arch/sparc64/stand/ofwboot/elf64_exec.c @@ -1,4 +1,4 @@ -/* $OpenBSD: elf64_exec.c,v 1.11 2020/05/25 15:31:59 kettenis Exp $ */ +/* $OpenBSD: elf64_exec.c,v 1.12 2020/06/13 12:25:09 kn Exp $ */ /* $NetBSD: elfXX_exec.c,v 1.2 2001/08/15 20:08:15 eeh Exp $ */ /* @@ -204,11 +204,24 @@ elf64_exec(int fd, Elf_Ehdr *elf, u_int64_t *entryp, void **ssymp, void **esymp) printf("read section headers: %s\n", strerror(errno)); return (1); } + + size_t shstrsz = shp[elf->e_shstrndx].sh_size; + char *shstr = alloc(shstrsz); + if (lseek(fd, (off_t)shp[elf->e_shstrndx].sh_offset, SEEK_SET) == -1) { + printf("lseek section header string table: %s\n", strerror(errno)); + return 1; + } + if (read(fd, shstr, shstrsz) != shstrsz) { + printf("read section header string table: %s\n", strerror(errno)); + return 1; + } + for (i = 0; i < elf->e_shnum; i++, shp++) { if (shp->sh_type == SHT_NULL) continue; if (shp->sh_type != SHT_SYMTAB - && shp->sh_type != SHT_STRTAB) { + && shp->sh_type != SHT_STRTAB + && strcmp(shstr + shp->sh_name, ELF_CTF)) { shp->sh_offset = 0; continue; } @@ -244,7 +257,8 @@ elf64_exec(int fd, Elf_Ehdr *elf, u_int64_t *entryp, void **ssymp, void **esymp) off = size; for (first = 1, i = 0; i < elf->e_shnum; i++, shp++) { if (shp->sh_type == SHT_SYMTAB - || shp->sh_type == SHT_STRTAB) { + || shp->sh_type == SHT_STRTAB + || !strcmp(shstr + shp->sh_name, ELF_CTF)) { if (first) printf("symbols @ 0x%lx ", (u_long)addr); printf("%s%d", first ? "" : "+", (int)shp->sh_size); @@ -255,6 +269,7 @@ elf64_exec(int fd, Elf_Ehdr *elf, u_int64_t *entryp, void **ssymp, void **esymp) } addr += ELF_ALIGN(shp->sh_size); shp->sh_offset = off; + shp->sh_flags |= SHF_ALLOC; off += ELF_ALIGN(shp->sh_size); first = 0; } diff --git a/sys/arch/sparc64/stand/ofwboot/vers.c b/sys/arch/sparc64/stand/ofwboot/vers.c index cc2630e4e70..2a743eee20b 100644 --- a/sys/arch/sparc64/stand/ofwboot/vers.c +++ b/sys/arch/sparc64/stand/ofwboot/vers.c @@ -1 +1 @@ -const char version[] = "1.19"; +const char version[] = "1.20"; |