From: Michael Jeanson Date: Tue, 29 Nov 2022 17:10:17 +0000 (-0500) Subject: fix: kallsyms wrapper on CONFIG_PPC64_ELF_ABI_V1 X-Git-Tag: v2.13.10~3 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=928a843e1f731fd83e17ff90af697eb39387d7f7;p=lttng-modules.git fix: kallsyms wrapper on CONFIG_PPC64_ELF_ABI_V1 Change-Id: Ibdff5792a1511b678f7776f5d032758db739c5ad Signed-off-by: Michael Jeanson Signed-off-by: Mathieu Desnoyers --- diff --git a/src/wrapper/kallsyms.c b/src/wrapper/kallsyms.c index 061224de..97897c42 100644 --- a/src/wrapper/kallsyms.c +++ b/src/wrapper/kallsyms.c @@ -20,6 +20,25 @@ # error "LTTng-modules requires CONFIG_KPROBES on kernels >= 5.7.0" #endif +#ifdef LTTNG_CONFIG_PPC64_ELF_ABI_V1 +#if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(5,18,0)) +#include + +#define LTTNG_FUNC_DESC_TYPE struct func_desc +#define LTTNG_FUNC_DESC_ADDR_NAME addr + +#else + +#include + +#define LTTNG_FUNC_DESC_TYPE func_descr_t +#define LTTNG_FUNC_DESC_ADDR_NAME entry +#endif + +static +LTTNG_FUNC_DESC_TYPE kallsyms_lookup_name_func_desc; +#endif + static unsigned long (*kallsyms_lookup_name_sym)(const char *name); @@ -56,6 +75,16 @@ unsigned long do_get_kallsyms(void) #ifdef LTTNG_CONFIG_PPC64_ELF_ABI_V2 /* Substract 4 bytes to get what we originally want */ addr = (unsigned long)(((char *)probe.addr) - 4); +#elif defined(LTTNG_CONFIG_PPC64_ELF_ABI_V1) + /* + * Build a function descriptor from the address of + * 'kallsyms_lookup_name' returned by kprobe and the toc of + * 'sprint_symbol' which is in the same compile unit and exported. I + * hate this on so many levels but it works. + */ + kallsyms_lookup_name_func_desc.LTTNG_FUNC_DESC_ADDR_NAME = (unsigned long) probe.addr; + kallsyms_lookup_name_func_desc.toc = ((LTTNG_FUNC_DESC_TYPE *) &sprint_symbol)->toc; + addr = (unsigned long) &kallsyms_lookup_name_func_desc; #else addr = (unsigned long)probe.addr; #endif