Sponsored Content
Top Forums Programming Make cannot generate .ko linux kernel module Post 302577065 by vistastar on Monday 28th of November 2011 06:11:06 AM
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..
 

9 More Discussions You Might Find Interesting

1. 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

2. 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

3. 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

4. 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

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. 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

7. 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

8. 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

9. 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
CREATE_MAKEFILES()														CREATE_MAKEFILES()

NAME
create_makefiles - Recreates all Makefiles beneath a directory SYNOPSIS
create_makefiles [dir] DESCRIPTION
create_makefiles recreates all Makefiles in dir and its (recursed) subdirectories from the corresponding Makefile.am templates. This script must be run from the toplevel directory (the one containing configure). This script saves time compared to re-running configure completely. If the source directory is different from the build directory (see the environment variables below), it will be assumed that each Makefile.am and Makefile.in belongs beneath the source directory and that each Makefile belongs beneath the build directory. This utility is part of the KDE Software Development Kit. ENVIRONMENT
One of the following variables (but not both) should be set if the source directory is different from the build directory. If the build directory is simply a subdirectory of the source directory, the simpler variable OBJ_SUBDIR should be used. OBJ_SUBJDIR Indicates that the build directory is in the given subdirectory of the source directory. For instance, if the source directory is kdesdk and the build directory is kdesdk/obj-i386-linux, then OBJ_SUBDIR should be set to obj-i386-linux. OBJ_REPLACEMENT A sed expression that is used to transform the source directory into the build directory. For instance, if the source directory is kdesdk/obj-i386-linux, then OBJ_REPLACEMENT should be set to s#kdesdk#kdesdk-obj#. SEE ALSO
create_makefile(1) make(2) AUTHORS
create_makefiles was written by David Faure<faure@kde.org>. This manual page was prepared by Ben Burton<bab@debian.org> for the Debian GNU/Linux system (but may be used by others). CREATE_MAKEFILES()
All times are GMT -4. The time now is 02:52 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy