ksyms: Fixup symbols for powerpc in the kernel, not just modules

Summary:
PowerPC kernels are fully position independent, just like kernel modules.
The same fixups that are done for modules therefore need to be done to the
kernel, else symbol resolution in, e.g., DTrace, cannot resolve the kernel
symbols, so only addresses in the kernel are printed, while kernel module
symbols are printed.

Test Plan:
Run lockstat on powerpc64.  Note symbols are resolved for kernel and
modules.

Reviewed By: markj
Differential Revision: https://reviews.freebsd.org/D20316
This commit is contained in:
Justin Hibbits 2019-05-20 02:41:09 +00:00
parent e2e050c8ef
commit 8740b33851
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=347985

View File

@ -191,6 +191,7 @@ ksyms_add(linker_file_t lf, void *arg)
size_t len, numsyms, strsz, symsz;
linker_symval_t symval;
int error, i, nsyms;
bool fixup;
buf = malloc(SYMBLKSZ, M_KSYMS, M_WAITOK);
to = arg;
@ -201,6 +202,12 @@ ksyms_add(linker_file_t lf, void *arg)
strsz = LINKER_STRTAB_GET(lf, &strtab);
symsz = numsyms * sizeof(Elf_Sym);
#ifdef __powerpc__
fixup = true;
#else
fixup = lf->id > 1;
#endif
while (symsz > 0) {
len = min(SYMBLKSZ, symsz);
bcopy(symtab, buf, len);
@ -214,7 +221,7 @@ ksyms_add(linker_file_t lf, void *arg)
nsyms = len / sizeof(Elf_Sym);
for (i = 0; i < nsyms; i++) {
symp[i].st_name += to->to_stridx;
if (lf->id > 1 && LINKER_SYMBOL_VALUES(lf,
if (fixup && LINKER_SYMBOL_VALUES(lf,
(c_linker_sym_t)&symtab[i], &symval) == 0) {
symp[i].st_value = (uintptr_t)symval.value;
}