+ -
当前位置:首页 → 问答吧 → 一个简单的模块问题

一个简单的模块问题

时间:2010-08-20

来源:互联网

  1. #include <linux/init.h>
  2. #include <linux/module.h>
  3. #include <linux/kernel.h>

  4. int __init init(void)
  5. {
  6.      int i = 0;
  7.      int *p = 0;
  8.      *p = i+1;
  9.      return 0;
  10. }

  11. void __exit fint(void)
  12. {
  13.      return;
  14. }
  15. module_init(init)
  16. module_exit(fint)

  17. MODULE_LICENSE("GPL");
  18. MODULE_AUTHOR("ZX");
复制代码
这个加载时会出错

错误信息如下


Message from syslogd@localhost at Aug 20 23:09:08 ...
kernel:Oops: 0002 [#1] SMP

Message from syslogd@localhost at Aug 20 23:09:08 ...
kernel:last sysfs file: /sys/devices/virtual/net/lo/type

Message from syslogd@localhost at Aug 20 23:09:08 ...
kernelrocess insmod (pid: 2446, ti=f1960000 task=ec913fc0 task.ti=f1960000)

Message from syslogd@localhost at Aug 20 23:09:08 ...
kernel:Stack:

Message from syslogd@localhost at Aug 20 23:09:08 ...
kernel:Call Trace:

Message from syslogd@localhost at Aug 20 23:09:08 ...
kernel:Code: <c7> 05 00 00 00 00 01 00 00 00 5d c3 00 00 00 00 00 00 00 00 00 00

Message from syslogd@localhost at Aug 20 23:09:08 ...
kernel:EIP: [<f8b36005>] init_module+0x5/0x11 [crash] SS:ESP 0068:f1961f84

Message from syslogd@localhost at Aug 20 23:09:08 ...
kernel:CR2: 0000000000000000
已杀死

反汇编的代码是
  1. crash.ko:     file format elf32-i386


  2. Disassembly of section .init.text:

  3. 00000000 <init>:
  4.    0:        55                           push   %ebp
  5.    1:        31 c0                        xor    %eax,%eax
  6.    3:        89 e5                        mov    %esp,%ebp
  7.    5:        c7 05 00 00 00 00 01         movl   $0x1,0x0
  8.    c:        00 00 00
  9.    f:        5d                           pop    %ebp
  10.   10:        c3                           ret   

  11. Disassembly of section .exit.text:

  12. 00000000 <cleanup_module>:
  13.    0:        55                           push   %ebp
  14.    1:        89 e5                        mov    %esp,%ebp
  15.    3:        e8 fc ff ff ff               call   4 <cleanup_module+0x4>
  16.    8:        5d                           pop    %ebp
  17.    9:        c3                           ret  
复制代码
1 我想问下f8b36005这个地址是怎么来的?模块的都是以f开头的吗(fxxx xxxx)
2 插入模块出错后,就不能卸载了。只有重启吗?还有其它的方法吗?

作者: donotgiveup   发布时间: 2010-08-20



QUOTE:
1 我想问下f8b36005这个地址是怎么来的?模块的都是以f开头的吗(fxxx xxxx)


提示信息中说这个是EIP的地址,也就是出现oops 的当前指令的地址


QUOTE:
2 插入模块出错后,就不能卸载了。只有重启吗?还有其它的方法吗?


因为出现oops了,系统有异常了。最好还是重启。

作者: Godbach   发布时间: 2010-08-22