]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
kallsyms: make it possible to disable /proc/kallmodsyms
authorNick Alcock <nick.alcock@oracle.com>
Mon, 3 Aug 2015 12:40:29 +0000 (13:40 +0100)
committerNick Alcock <nick.alcock@oracle.com>
Wed, 5 Aug 2015 21:17:43 +0000 (22:17 +0100)
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

init/Kconfig
kernel/dtrace/Kconfig
kernel/kallsyms.c
scripts/Makefile
scripts/kallsyms.c

index 75242761fe6d24c5b80aae5a9c6131ab14a5d144..598f817c43e28e9115a2156a16eb220e935bce3d 100644 (file)
@@ -1434,6 +1434,15 @@ config KALLSYMS_ALL
 
           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
index 80aadd503d4a502631548b2ebac12c70adfb0e4f..80a0262d3d94ed4fe3c15967aa3bb4dd1101b6a7 100644 (file)
@@ -9,6 +9,7 @@ menuconfig DTRACE
        depends on ARCH_SUPPORTS_DTRACE
        depends on !DEBUG_LOCK_ALLOC
        select KALLSYMS
+       select KALLMODSYMS
        select WAITFD
        select CTF if (!DT_DISABLE_CTF)
        help
index c3cf2a24f29bafcd72f7dc349370a7ea8a92c915..d76c562b8b9cd1ec8a77163e67da5433721d9d4b 100644 (file)
@@ -486,9 +486,12 @@ static int get_ksymbol_mod(struct kallsym_iter *iter)
 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 {
@@ -593,11 +596,6 @@ static int s_show(struct seq_file *m, void *p)
        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,
@@ -605,12 +603,19 @@ static const struct seq_operations kallsyms_op = {
        .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)
@@ -634,10 +639,12 @@ static int kallsyms_open(struct inode *inode, struct file *file)
        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)
@@ -666,17 +673,21 @@ static const struct file_operations kallsyms_operations = {
        .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);
index e7e81b87841d08917ddcd98d490dd742f5a3a473..a9f02e69f6dd5cc954952a834ae4950d28f5a883 100644 (file)
@@ -22,11 +22,15 @@ HOSTCFLAGS_asn1_compiler.o = -I$(srctree)/include
 
 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
index 9b3941d50aa0b1860662d9b4117d8eee1fd20e77..b55aa633e9c40802f9e1b0c4b7419bdc542c743d 100644 (file)
@@ -28,6 +28,7 @@
 #include <errno.h>
 #include <unistd.h>
 
+#ifdef CONFIG_KALLMODSYMS
 #include <libelf.h>
 #include <dwarf.h>
 #include <elfutils/libdwfl.h>
@@ -35,6 +36,7 @@
 #include <glib.h>
 
 #include <eu_simple.h>
+#endif
 
 #ifndef ARRAY_SIZE
 #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof(arr[0]))
@@ -82,18 +84,13 @@ int token_profit[0x10000];
 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
@@ -101,6 +98,13 @@ static unsigned int *builtin_module_offsets;
  * 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)
 {
@@ -194,8 +198,12 @@ static int read_symbol(FILE *in, struct sym_entry *s)
        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];
@@ -463,6 +471,7 @@ static void write_src(void)
                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]);
@@ -472,6 +481,7 @@ static void write_src(void)
        for (i = 0; i < table_cnt; i++)
                printf("\t.int\t%d\n", table[i].module);
        printf("\n");
+#endif
 }
 
 /* table lookup compression functions */
@@ -739,6 +749,7 @@ static void make_percpus_absolute(void)
                        table[i].sym[0] = 'A';
 }
 
+#ifdef CONFIG_KALLMODSYMS
 /* Built-in module list computation. */
 
 /*
@@ -979,6 +990,9 @@ static void read_modules(const char *modules_builtin)
        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)
 {