[DTrace-devel] [PATCH 5/7] module: use uintptr_t as type for kernel symbols withuot type info
Kris Van Hees
kris.van.hees at oracle.com
Tue Oct 31 15:25:35 UTC 2023
When a kernel symbol is known to exist (found in kallsyms) but no type
information can be found, a compilation error is reported. That makes
it impossible to use casting to resolve missing type information for
symbols whose address is clearly known. So, assign those symbol the
uintptr_t type.
Signed-off-by: Kris Van Hees <kris.van.hees at oracle.com>
---
libdtrace/dt_module.c | 23 +++++++++++++++++------
1 file changed, 17 insertions(+), 6 deletions(-)
diff --git a/libdtrace/dt_module.c b/libdtrace/dt_module.c
index bb8c030d..5d67bdc6 100644
--- a/libdtrace/dt_module.c
+++ b/libdtrace/dt_module.c
@@ -1759,20 +1759,31 @@ dtrace_symbol_type(dtrace_hdl_t *dtp, const GElf_Sym *symp,
tip->dtt_type = DT_FPTR_TYPE(dtp);
}
- if (undefined) {
- if (dmp->dm_extern == NULL)
- return dt_set_errno(dtp, EDT_NOSYM);
+ if (!undefined)
+ goto out;
- dt_ident_t *idp =
- dt_idhash_lookup(dmp->dm_extern, sip->name);
+ /*
+ * Try externs for the module (if any). If that fails, and we are
+ * looking for a symbol in a kernel module, default to uintptr_t.
+ */
+ if (dmp->dm_extern != NULL) {
+ dt_ident_t *idp = dt_idhash_lookup(dmp->dm_extern, sip->name);
if (idp == NULL)
return dt_set_errno(dtp, EDT_NOSYM);
tip->dtt_ctfp = idp->di_ctfp;
tip->dtt_type = idp->di_type;
- }
+ } else if (dmp->dm_flags & DT_DM_KERNEL) {
+ tip->dtt_ctfp = dmp->dm_ctfp;
+ tip->dtt_type = ctf_lookup_by_name(dmp->dm_ctfp, "uintptr_t");
+
+ if (tip->dtt_type == CTF_ERR)
+ return dt_set_errno(dtp, EDT_NOSYM);
+ } else
+ return dt_set_errno(dtp, EDT_NOSYM);
+out:
tip->dtt_object = dmp->dm_name;
return 0;
}
--
2.39.2
More information about the DTrace-devel
mailing list