summaryrefslogtreecommitdiff
path: root/sys/arch
diff options
context:
space:
mode:
authorMark Kettenis <kettenis@cvs.openbsd.org>2020-08-29 09:17:18 +0000
committerMark Kettenis <kettenis@cvs.openbsd.org>2020-08-29 09:17:18 +0000
commit5e9031eca8e66577e7460657d367a589063da331 (patch)
tree150eddb0896c280ca0df0997f0d5d8867f4f45ee /sys/arch
parentd8b5fd6bcb738c7256431af8964887c117995fb9 (diff)
Mark certain sections with debug information as "allocated" such that they
get picked up by ddb. This makes the "pp" and "show struct" commands that depends on CTF work. ok gkoehler@
Diffstat (limited to 'sys/arch')
-rw-r--r--sys/arch/powerpc64/dev/kexec.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/sys/arch/powerpc64/dev/kexec.c b/sys/arch/powerpc64/dev/kexec.c
index a9a568aa201..00b0cd38317 100644
--- a/sys/arch/powerpc64/dev/kexec.c
+++ b/sys/arch/powerpc64/dev/kexec.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kexec.c,v 1.3 2020/07/18 20:02:34 kettenis Exp $ */
+/* $OpenBSD: kexec.c,v 1.4 2020/08/29 09:17:17 kettenis Exp $ */
/*
* Copyright (c) 2019-2020 Visa Hankala
@@ -89,7 +89,7 @@ kexec_kexec(struct kexec_args *kargs, struct proc *p)
};
Elf_Ehdr eh;
Elf_Phdr *ph = NULL;
- Elf_Shdr *sh = NULL;
+ Elf_Shdr *sh = NULL, *shp;
vaddr_t start = VM_MAX_ADDRESS;
vaddr_t end = 0;
paddr_t start_pa, initrd_pa;
@@ -97,6 +97,7 @@ kexec_kexec(struct kexec_args *kargs, struct proc *p)
caddr_t addr = NULL;
caddr_t symaddr = NULL;
size_t phsize, shsize, size, symsize;
+ char *shstr;
void *node;
int error, random, i;
@@ -189,6 +190,17 @@ kexec_kexec(struct kexec_args *kargs, struct proc *p)
if (error != 0)
goto fail;
+ shp = (Elf64_Shdr *)(symaddr + eh.e_shoff);
+ shstr = symaddr + shp[eh.e_shstrndx].sh_offset;
+ for (i = 0; i < eh.e_shnum; i++) {
+ if (shp[i].sh_type == SHT_SYMTAB ||
+ shp[i].sh_type == SHT_STRTAB ||
+ strcmp(shstr + shp[i].sh_name, ".debug_line") == 0 ||
+ strcmp(shstr + shp[i].sh_name, ELF_CTF) == 0)
+ if (shp[i].sh_offset + shp[i].sh_size <= symsize)
+ shp[i].sh_flags |= SHF_ALLOC;
+ }
+
pmap_extract(pmap_kernel(), (vaddr_t)symaddr, &initrd_pa);
node = fdt_find_node("/chosen");