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:
jhibbits 2019-05-20 02:41:09 +00:00
parent 250e158ddf
commit d864978fc6

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;
}