title: "Unknown symbol in module" error while inserting kernel module
body: <p>I created the following error-prone kernel module for educational purposes.</p>
  
  <pre><code>#include &lt;linux/module.h&gt;
  #include &lt;linux/kernel.h&gt;
  #include &lt;linux/init.h&gt;
  #include &lt;linux/proc_fs.h&gt;
  #include &lt;linux/string.h&gt;
  #include &lt;asm/uaccess.h&gt;
  
  void *(my_funptr)(void);
  
  int bug1_write(struct file *file,
                 const char *buf,
                 unsigned long len) {
          my_funptr();
          return len;
  }
  
  int init_module(void) {
          static struct proc_dir_entry *proc;
          proc = create_proc_entry("bug1", 0666, 0);
          proc-&gt;write_proc = bug1_write;
          return 0;
  }
  </code></pre>
  
  <p>I compiled it using the following Makefile :-</p>
  
  <pre><code>obj-m += bug1.o
  
  all:
      make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
  clean:
      make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean
  </code></pre>
  
  <p>Compiling gave me :-</p>
  
  <pre><code>$ make
  make -C /lib/modules/3.0.0-13-generic-pae/build M=/home/fusion/kernel_exp modules
  make[1]: Entering directory `/usr/src/linux-headers-3.0.0-13-generic-pae'
    Building modules, stage 2.
    MODPOST 1 modules
  WARNING: "my_funptr" [/home/fusion/kernel_exp/bug1.ko] undefined!
  make[1]: Leaving directory `/usr/src/linux-headers-3.0.0-13-generic-pae'
  </code></pre>
  
  <p>Trying to install the kernel module :-</p>
  
  <pre><code>$ sudo insmod bug1.ko
  [sudo] password for fusion:
  insmod: error inserting 'bug1.ko': -1 Unknown symbol in module
  </code></pre>
  
  <p>Given that the code is intentionally buggy, I'd really like to be able to compile and insert the kernel module -- is there any compiler flag I could use to be able to do this? Any documentation you could point me toward, that I could refer? Thanks.</p>