Index: sys/kern/kern_linker.c =================================================================== --- sys/kern/kern_linker.c +++ sys/kern/kern_linker.c @@ -1992,7 +1992,7 @@ TAILQ_FOREACH(lf, &linker_files, link) { /* Save the info for this linker file. */ - kobase[i].pm_file = lf->filename; + kobase[i].pm_file = lf->pathname; kobase[i].pm_address = (uintptr_t)lf->address; i++; } Index: sys/kern/link_elf_obj.c =================================================================== --- sys/kern/link_elf_obj.c +++ sys/kern/link_elf_obj.c @@ -481,6 +481,7 @@ Elf_Ehdr *hdr; Elf_Shdr *shdr; Elf_Sym *es; + char *fullpath, *freepath; int nbytes, i, j; vm_offset_t mapbase; size_t mapsize; @@ -557,7 +558,13 @@ goto out; } - lf = linker_make_file(filename, &link_elf_class); + /* Try to get the full path, hwpmc(4) will use it. */ + fullpath = __DECONST(char *, filename); + freepath = NULL; + vn_fullpath(td, nd.ni_vp, &fullpath, &freepath); + + lf = linker_make_file(fullpath, &link_elf_class); + free(freepath, M_TEMP); if (!lf) { error = ENOMEM; goto out; Index: usr.sbin/pmcstat/pmcstat_log.c =================================================================== --- usr.sbin/pmcstat/pmcstat_log.c +++ usr.sbin/pmcstat/pmcstat_log.c @@ -646,7 +646,7 @@ * Look for kernel modules under FSROOT/KERNELPATH/NAME, * and user mode executable objects under FSROOT/PATHNAME. */ - if (image->pi_iskernelmodule) + if (image->pi_iskernelmodule && path[0] != '/') (void) snprintf(buffer, sizeof(buffer), "%s%s/%s", args.pa_fsroot, args.pa_kernel, path); else