5 #include <sys/linker.h>
6 #include <sys/sysctl.h>
15 /* Things which get -E excluded by default. */
16 static char *excludes[] = { ".mcount", "_mcleanup", NULL };
19 kernel_getnfile(const char *unused __unused, char ***defaultEs)
25 if (sysctlbyname("kern.function_list", NULL, &len, NULL, 0) == -1)
26 err(1, "sysctlbyname: function_list size");
28 namelist = malloc(len);
31 if (sysctlbyname("kern.function_list", namelist, &len, NULL,
37 err(1, "sysctlbyname: function_list");
40 for (name = namelist; *name != '\0'; name += strlen(name) + 1)
42 /* Allocate memory for them, plus a terminating entry. */
43 if ((nl = (nltype *)calloc(nname + 1, sizeof(nltype))) == NULL)
44 errx(1, "Insufficient memory for symbol table");
46 for (name = namelist; *name != '\0'; name += strlen(name) + 1) {
47 struct kld_sym_lookup ksl;
49 ksl.version = sizeof(ksl);
51 if (kldsym(0, KLDSYM_LOOKUP, &ksl))
52 err(1, "kldsym(%s)", name);
53 /* aflag not supported */
54 if (uflag && strchr(name, '.') != NULL)
56 npe->value = ksl.symvalue;
62 *defaultEs = excludes;