Make cannot generate .ko linux kernel module


 
Thread Tools Search this Thread
Top Forums Programming Make cannot generate .ko linux kernel module
# 1  
Old 11-28-2011
Make cannot generate .ko linux kernel module

cannot generate .ko file on my linux, although it can generate module.symvers.
But when I copy .c file and Makefile to another linux computer, there's no problem.

The strange thing is: make is successfuly executed, and returned 0;
Code:
make output:

	make -C /lib/modules/2.6.18-92.el5xen/build  
	M=/home/ye         modules
	make[1]: Entering directory `/usr/src/kernels/2.6.18-92.el5-xen-i686' 
	Building modules, stage 2. 
	MODPOST 
	make[1]: Leaving directory  `/usr/src/kernels/2.6.18-92.el5-xen-i686'


system: RHEL5
Code:
Makefile:
  1 ifneq ($(KERNELRELEASE),)
  2     obj-m:=hello.o
  3 else
  4     KDIR:=/lib/modules/$(shell uname -r)/build
  5     PWD:=$(shell pwd)
  6 default:
  7     $(MAKE) -C $(KDIR) M=$(PWD) modules
  8 clean:
  9     $(MAKE) -C $(KDIR) M=$(PWD) clean 
 10 endif

Code:
hello.c

 1 #include<linux/init.h>
  2 #include<linux/module.h>
  3 #include<linux/moduleparam.h>
  4 
  5 MODULE_LICENSE("GPL");
  6 
  7 static char *my_string = "parameter";
  8 static int my_int = 1;
  9 
 10 module_param(my_string,charp,S_IRUGO);
 11 module_param(my_int,int,S_IRUGO);
 12 
 13 
 14 static int hello_init(void){
 15     
 16     
 17 
 18     printk(KERN_ALERT "%s %d\n",my_string,my_int);
 19     return 0;
 20 }
 21 
 22 static void hello_exit(void){
 23     printk(KERN_ALERT "goodbye\n");
 24 }
 25 
 26 module_init(hello_init);
 27 module_exit(hello_exit);


Last edited by vistastar; 11-28-2011 at 07:40 AM..
# 2  
Old 11-28-2011
That is strange... have you tried doing an "updatedb && locate whatever.ko"?
# 3  
Old 11-28-2011
The kernel source does the majority of the work for this makefile. Any problem with that will prevent it from working. Make sure you have a compatible kernel, the right headers are installed, etc.
# 4  
Old 11-30-2011
it isn't what I want.
I need a tool like winhex which can check the entire virtual memory of a process.
# 5  
Old 11-30-2011
Pretty sure you can do that without modifying the kernel. You can get a complete map of valid memory segments via /proc/pid/map, and things like gdb peek into the memory of child processes all the time.

---------- Post updated at 09:50 AM ---------- Previous update was at 09:46 AM ----------

here is another thread on the subject.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Linux

Unload kernel module at boot time (Debian Wheezy 7.2, 3.2.0-4-686-pae kernel)

Hi everyone, I am trying to prevent the ehci_hcd kernel module to load at boot time. Here's what I've tried so far: 1) Add the following line to /etc/modprobe.d/blacklist.conf (as suggested here): 2) Blacklisted the module by adding the following string to 3) Tried to blacklist the module... (0 Replies)
Discussion started by: gacanepa
0 Replies

2. UNIX for Advanced & Expert Users

Get pointer for existing device class (struct class) in Linux kernel module

Hi all! I am trying to register a device in an existing device class, but I am having trouble getting the pointer to an existing class. I can create a class in a module, get the pointer to it and then use it to register the device with: *cl = class_create(THIS_MODULE, className);... (0 Replies)
Discussion started by: hdaniel@ualg.pt
0 Replies

3. UNIX for Advanced & Expert Users

Kernel Module Debugging

Question may seem illogical but I still need clarification. Can we debug kernel modules loaded on my target system using kdb / kgdb without using any other system or remote debugging? In other words my question is can we use kdb/kgdb to debug kernel modules running on same system? (2 Replies)
Discussion started by: rupeshkp728
2 Replies

4. Programming

can a linux kernel module call libc functions?

can a linux kernel module call libc functions, such as printf(), strcpy(), etc...? (9 Replies)
Discussion started by: vistastar
9 Replies

5. IP Networking

kernel module

Hi All, I need to develop a kernel module which changes the IP address of a package according to its mac address. It would be a sort of L2 Nat. Somebody know if I can do this using netfilter?? Thanks. (2 Replies)
Discussion started by: lagigliaivan
2 Replies

6. Linux

How to convert Linux Kernel built-in module into a loadable module

Hi all, I am working on USB data monitoring on Fedora Core 9. Kernel 2.6.25 has a built-in module (the one that isn't loadable, but compiles and links statically with the kernel during compilation) to snoop USB data. It is in <kernel_source_code>/drivers/usb/mon/. I need to know if I can... (0 Replies)
Discussion started by: anitemp
0 Replies

7. UNIX for Dummies Questions & Answers

Linux kernel module parameters

Hi, Does anyone know if it is possible to know the current value of a kernel module parameters after the module is loaded. Are the values of the parameters advertised at some /proc or /sys location ? The only thing I know is modinfo, that actually looks a the module .ko and gives a... (3 Replies)
Discussion started by: macL
3 Replies

8. SuSE

max number of slabs per kernel module (kernel 2.6.17, suse)

Hi All, Is there a max number of slabs that can be used per kernel module? I'm having a tough time finding out that kind of information, but the array 'node_zonelists' (mmzone.h) has a size of 5. I just want to avoid buffer overruns and other bad stuff. Cheers, Brendan (4 Replies)
Discussion started by: Brendan Kennedy
4 Replies

9. Linux

Making Socket System Call From Linux Kernel Module?

Hi Everyone! How can we make a socket() system call from a linux module executing in kernel space? If any one knows, kindly tell me. It will be great. I want to use the socket interface in linux kernel space for sending raw packets over the network. Hamayun (0 Replies)
Discussion started by: mian_m_hamayun
0 Replies
Login or Register to Ask a Question