title: insmod: error inserting 'hello_world.ko': -1 Invalid module format
body: <p>My environment:</p>
  
  <pre><code>[root@localhost hello_world]# uname -a
  Linux localhost.localdomain 2.6.32-504.el6.x86_64 #1 SMP Wed Oct 15 04:27:16 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux
  [root@localhost hello_world]# cat /etc/issue
  CentOS release 6.6 (Final)
  Kernel \r on an \m
  </code></pre>
  
  <p>and kernel source tree version is:</p>
  
  <pre><code>[root@localhost lab]# ls /home/bruce/rpmbuild/BUILD/kernel-2.6.32-504.el6/
  linux-2.6.32-504.el6.x86_64
  [root@localhost lab]# rpm -qa kernel\* | sort
  kernel-2.6.32-504.el6.x86_64
  kernel-firmware-2.6.32-504.el6.noarch
  kernel-headers-2.6.32-504.el6.x86_64
  </code></pre>
  
  <p>that generated followed by wiki: <a href="http://wiki.centos.org/HowTos/I_need_the_Kernel_Source" rel="nofollow">I Need the Kernel Source</a></p>
  
  <p>A simple kernel "hello world":</p>
  
  <pre><code>#include &lt;linux/module.h&gt;       /* Needed by all modules */
  #include &lt;linux/kernel.h&gt;       /* Needed for KERN_ALERT */
  
  int init_module(void)
  {
      printk(KERN_INFO "Hello world.\n");
      return 0;
  }
  
  void cleanup_module(void)
  {
      printk(KERN_INFO "Goodbye world.\n");
  }
  </code></pre>
  
  <p>and Makefile:</p>
  
  <pre><code>KERNEL_SOURCE_VERSION ?= $(shell uname -r)
  KERNEL_TREE ?= /lib/modules/$(KERNEL_SOURCE_VERSION)/build
  obj-m += hello_world.o
  
  all:
          make -C $(KERNEL_TREE) M=$(PWD) modules
  clean:
          make -C $(KERNEL_TREE) M=$(PWD) clean
  </code></pre>
  
  <p>it make successfully. </p>
  
  <pre><code>[root@localhost hello_world]# modinfo hello_world.ko
  filename:       hello_world.ko
  srcversion:     67A7C9765BA14A0A1C8B6CF
  depends:        
  vermagic:       2.6.32 SMP mod_unload modversions
  </code></pre>
  
  <p>but when loads the hello_world.ko, it report errors:</p>
  
  <pre><code>[root@localhost hello_world]# insmod hello_world.ko
  insmod: error inserting 'hello_world.ko': -1 Invalid module format
  </code></pre>
  
  <p>and log message shows:</p>
  
  <pre><code>[root@localhost hello_world]# tail -n 2 /var/log/messages 
  Feb  2 22:09:47 localhost kernel: hello_world: no symbol version for module_layout
  Feb  2 22:10:12 localhost kernel: hello_world: no symbol version for module_layout
  </code></pre>
  
  <p>It's my first kernel program, I think the version between kernel source and system kernel is matched. 
  So what's the problem?</p>