Skip to content

Commit

Permalink
module: use uintptr_t as type for kernel symbols withuot type info
Browse files Browse the repository at this point in the history
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@oracle.com>
Reviewed-by: Nick Alcock <nick.alcock@oracle.com>
  • Loading branch information
kvanhees committed Nov 8, 2023
1 parent defa682 commit a2343d6
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions libdtrace/dt_module.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit a2343d6

Please sign in to comment.