Date: Thu, 10 May 2018 03:59:49 +0000 (UTC) From: Justin Hibbits <jhibbits@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r333447 - in head/sys: ddb powerpc/include powerpc/pseries Message-ID: <201805100359.w4A3xnpY099886@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: jhibbits Date: Thu May 10 03:59:48 2018 New Revision: 333447 URL: https://svnweb.freebsd.org/changeset/base/333447 Log: Fix PPC symbol resolution Summary: There were 2 issues that were preventing correct symbol resolution on PowerPC/pseries: 1- memory corruption at chrp_attach() - this caused the inital part of the symbol table to become zeroed, which would cause the kernel linker to fail to parse it. (this was probably zeroing out other memory parts as well) 2- DDB symbol resolution wasn't working because symtab contained not relocated addresses but it was given relocated offsets. Although relocating the symbol table fixed this, it broke the linker, that already handled this case. Thus, the fix for this consists in adding a new DDB macro: DB_STOFFS(offs) that converts a (potentially) relocated offset into one that can be compared with symbol table values. PR: 227093 Submitted by: Leandro Lupori <leandro.lupori_gmail.com> Differential Revision: https://reviews.freebsd.org/D15372 Modified: head/sys/ddb/db_main.c head/sys/ddb/ddb.h head/sys/powerpc/include/db_machdep.h head/sys/powerpc/pseries/platform_chrp.c Modified: head/sys/ddb/db_main.c ============================================================================== --- head/sys/ddb/db_main.c Thu May 10 03:50:20 2018 (r333446) +++ head/sys/ddb/db_main.c Thu May 10 03:59:48 2018 (r333447) @@ -100,6 +100,7 @@ X_db_search_symbol(db_symtab_t *symtab, db_addr_t off, c_linker_sym_t lsym; Elf_Sym *sym, *match; unsigned long diff; + db_addr_t stoffs; if (symtab->private == NULL) { if (!linker_ddb_search_symbol((caddr_t)off, &lsym, &diff)) { @@ -111,19 +112,20 @@ X_db_search_symbol(db_symtab_t *symtab, db_addr_t off, diff = ~0UL; match = NULL; + stoffs = DB_STOFFS(off); for (sym = (Elf_Sym*)symtab->start; (char*)sym < symtab->end; sym++) { if (sym->st_name == 0 || sym->st_shndx == SHN_UNDEF) continue; - if (off < sym->st_value) + if (stoffs < sym->st_value) continue; if (ELF_ST_TYPE(sym->st_info) != STT_OBJECT && ELF_ST_TYPE(sym->st_info) != STT_FUNC && ELF_ST_TYPE(sym->st_info) != STT_NOTYPE) continue; - if ((off - sym->st_value) > diff) + if ((stoffs - sym->st_value) > diff) continue; - if ((off - sym->st_value) < diff) { - diff = off - sym->st_value; + if ((stoffs - sym->st_value) < diff) { + diff = stoffs - sym->st_value; match = sym; } else { if (match == NULL) Modified: head/sys/ddb/ddb.h ============================================================================== --- head/sys/ddb/ddb.h Thu May 10 03:50:20 2018 (r333446) +++ head/sys/ddb/ddb.h Thu May 10 03:59:48 2018 (r333447) @@ -72,6 +72,10 @@ SYSCTL_DECL(_debug_ddb); #define DB_MAXSCRIPTRECURSION 3 #endif +#ifndef DB_STOFFS +#define DB_STOFFS(offs) (offs) +#endif + #ifndef DB_CALL #define DB_CALL db_fncall_generic #else Modified: head/sys/powerpc/include/db_machdep.h ============================================================================== --- head/sys/powerpc/include/db_machdep.h Thu May 10 03:50:20 2018 (r333446) +++ head/sys/powerpc/include/db_machdep.h Thu May 10 03:59:48 2018 (r333447) @@ -85,4 +85,8 @@ typedef intptr_t db_expr_t; /* expression - signed */ #define inst_load(ins) 0 #define inst_store(ins) 0 +#ifdef __powerpc64__ +#define DB_STOFFS(offs) ((offs) & ~DMAP_BASE_ADDRESS) +#endif + #endif /* _POWERPC_DB_MACHDEP_H_ */ Modified: head/sys/powerpc/pseries/platform_chrp.c ============================================================================== --- head/sys/powerpc/pseries/platform_chrp.c Thu May 10 03:50:20 2018 (r333446) +++ head/sys/powerpc/pseries/platform_chrp.c Thu May 10 03:59:48 2018 (r333447) @@ -146,7 +146,7 @@ chrp_attach(platform_t plat) /* Set up important VPA fields */ for (i = 0; i < MAXCPU; i++) { - bzero(splpar_vpa[i], sizeof(splpar_vpa)); + bzero(splpar_vpa[i], sizeof(splpar_vpa[i])); /* First two: VPA size */ splpar_vpa[i][4] = (uint8_t)((sizeof(splpar_vpa[i]) >> 8) & 0xff);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201805100359.w4A3xnpY099886>