This allows you to build UEK without elfutils present at all, just like you
can with the upstream.
It requires a bit of fiddling about in kernel/kallsyms.c to make kallsyms
work with a NULL kallsyms_symbol_modules, and a bit of code motion to keep
the number of ifdefs down.
Verified that /proc/kallsyms has identical output (modulo only addresses,
dtrace-related symbols and, of course, the symbols ifdeffed out in this
patch) when the new CONFIG_KALLMODSYMS option is flipped.
Signed-off-by: Nick Alcock <nick.alcock@oracle.com>
Acked-by: Kris Van Hees <kris.van.hees@oracle.com>
Orabug:
21539840
Say N unless you really need all symbols.
+config KALLMODSYMS
+ default y
+ bool "Enable support for /proc/kallmodsyms" if EXPERT
+ depends on KALLSYMS
+ help
+ This option enables the /proc/kallmodsyms file, which maps symbols
+ to addresses and their associated modules. This support requires
+ a fairly recent elfutils.
+
config PRINTK
default y
bool "Enable support for printk" if EXPERT
depends on ARCH_SUPPORTS_DTRACE
depends on !DEBUG_LOCK_ALLOC
select KALLSYMS
+ select KALLMODSYMS
select WAITFD
select CTF if (!DT_DISABLE_CTF)
help
static unsigned long get_ksymbol_core(struct kallsym_iter *iter)
{
unsigned off = iter->nameoff;
- u32 mod_index = kallsyms_symbol_modules[iter->pos];
+ u32 mod_index = 0;
- if (mod_index == 0) {
+ if (kallsyms_symbol_modules)
+ mod_index = kallsyms_symbol_modules[iter->pos];
+
+ if (mod_index == 0 || kallsyms_modules == NULL) {
iter->module_name[0] = '\0';
iter->builtin_module = 0;
} else {
return s_show_internal(m, p, 0);
}
-static int s_mod_show(struct seq_file *m, void *p)
-{
- return s_show_internal(m, p, 1);
-}
-
static const struct seq_operations kallsyms_op = {
.start = s_start,
.next = s_next,
.show = s_show
};
+#ifdef CONFIG_KALLMODSYMS
+static int s_mod_show(struct seq_file *m, void *p)
+{
+ return s_show_internal(m, p, 1);
+}
+
static const struct seq_operations kallmodsyms_op = {
.start = s_start,
.next = s_next,
.stop = s_stop,
.show = s_mod_show
};
+#endif
static int kallsyms_open_internal(struct inode *inode, struct file *file,
const struct seq_operations *ops)
return kallsyms_open_internal(inode, file, &kallsyms_op);
}
+#ifdef CONFIG_KALLMODSYMS
static int kallmodsyms_open(struct inode *inode, struct file *file)
{
return kallsyms_open_internal(inode, file, &kallmodsyms_op);
}
+#endif
#ifdef CONFIG_KGDB_KDB
const char *kdb_walk_kallsyms(loff_t *pos)
.release = seq_release_private,
};
+#ifdef CONFIG_KALLMODSYMS
static const struct file_operations kallmodsyms_operations = {
.open = kallmodsyms_open,
.read = seq_read,
.llseek = seq_lseek,
.release = seq_release_private,
};
+#endif
static int __init kallsyms_init(void)
{
proc_create("kallsyms", 0444, NULL, &kallsyms_operations);
+#ifdef CONFIG_KALLMODSYMS
proc_create("kallmodsyms", 0444, NULL, &kallmodsyms_operations);
+#endif
return 0;
}
device_initcall(kallsyms_init);
always := $(hostprogs-y) $(hostprogs-m)
-kallsyms-objs := kallsyms.o eu_simple.o
+kallsyms-objs := kallsyms.o
+
+ifeq ($(CONFIG_KALLMODSYMS),y)
+kallsyms-objs += eu_simple.o
HOSTCFLAGS_eu_simple.o := -I$(srctree)/scripts
HOSTCFLAGS_kallsyms.o := $(shell pkg-config --cflags glib-2.0) -I$(srctree)/scripts
HOSTLOADLIBES_kallsyms := $(shell pkg-config --libs glib-2.0) -ldw
+endif
# The following hostprogs-y programs are only build on demand
hostprogs-y += unifdef docproc
#include <errno.h>
#include <unistd.h>
+#ifdef CONFIG_KALLMODSYMS
#include <libelf.h>
#include <dwarf.h>
#include <elfutils/libdwfl.h>
#include <glib.h>
#include <eu_simple.h>
+#endif
#ifndef ARRAY_SIZE
#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof(arr[0]))
unsigned char best_table[256][2];
unsigned char best_table_len[256];
+#ifdef CONFIG_KALLMODSYMS
/*
* The list of builtin module names.
*/
static char **builtin_modules;
static unsigned int builtin_module_size, builtin_module_len;
-/*
- * For each builtin module, its offset from the start of the builtin_module
- * list, assuming consecutive placement.
- */
-static unsigned int *builtin_module_offsets;
-
/*
* A mapping from symbol name to the index of the module it is part of in the
* builtin_modules list. Symbols within the same module share pointers to the
* quite space-efficient).
*/
static GHashTable *symbol_to_module;
+#endif
+
+/*
+ * For each builtin module, its offset from the start of the builtin_module
+ * list, assuming consecutive placement.
+ */
+static unsigned int *builtin_module_offsets;
static void usage(void)
{
else if (stype == 'N')
return -1;
+#ifdef CONFIG_KALLMODSYMS
/* look up the builtin module this is part of (if any). */
module = g_hash_table_lookup(symbol_to_module, sym);
+#else
+ module = 0;
+#endif
if (module)
s->module = builtin_module_offsets[*module];
printf("\t.short\t%d\n", best_idx[i]);
printf("\n");
+#ifdef CONFIG_KALLMODSYMS
output_label("kallsyms_modules");
for (i = 0; i < builtin_module_len; i++)
printf("\t.asciz\t\"%s\"\n", builtin_modules[i]);
for (i = 0; i < table_cnt; i++)
printf("\t.int\t%d\n", table[i].module);
printf("\n");
+#endif
}
/* table lookup compression functions */
table[i].sym[0] = 'A';
}
+#ifdef CONFIG_KALLMODSYMS
/* Built-in module list computation. */
/*
fclose(f);
g_hash_table_destroy(module_symbol_seen);
}
+#else
+static void read_modules(const char *unused) {}
+#endif /* CONFIG_KALLMODSYMS */
int main(int argc, char **argv)
{