LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   Problems building a simple kernel module for kernel 2.6.7 (https://www.linuxquestions.org/questions/linux-software-2/problems-building-a-simple-kernel-module-for-kernel-2-6-7-a-265964/)

atticman 12-13-2004 12:14 PM

Problems building a simple kernel module for kernel 2.6.7
 
Hi,
I'm a newbie to Linux and I'm trying to build a simple kernel module with some problems. I'm calling an external C function in the kernel source and I'm getting "implicit declaration" warnings in the first pass and undefined symbols in the MODPOST pass. I don't understand why I'm getting these.

The module will not even load due to these errors. Here is the error I get when I do "insmod mcf25.ko":

insmod: error inserting 'mcf25.ko': -1 Unknown symbol in module

Which is interesting that if I take out the "CardServices" function call, building and insmoding work just fine.

I've pasted my source (which is small) and the Makefile also.

This is Slackware 10. I'm sure there is something extremely simple that I didn't do, I just don't know what the heck it is.

Thanks!!!

---- Source ----

#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/init.h>
#include <linux/sched.h>
#include <linux/ptrace.h>
#include <linux/slab.h>
#include <linux/string.h>
#include <linux/timer.h>
#include <linux/ioport.h>
#include <asm/io.h>
#include <asm/system.h>

#include <linux/netdevice.h>
#include <linux/etherdevice.h>
#include <linux/skbuff.h>
#include <linux/if_arp.h>
#include <linux/ioport.h>
#include <linux/config.h>

#include <pcmcia/version.h>
#include <pcmcia/cs_types.h>
#include <pcmcia/cs.h>
#include <pcmcia/cistpl.h>
#include <pcmcia/cisreg.h>
#include <pcmcia/ds.h>
//#include <pcmcia/bus_ops.h>
#include "mcf25.h"

MODULE_LICENSE("GPL");

static int __init init_mcf25_cs(void)
{
servinfo_t serv;

printk(KERN_ALERT"TEST: (test2) in module MCF25!\n");

CardServices(GetCardServicesInfo, &serv);

return 0;
}

static void __exit exit_mcf25_cs(void)
{
printk(KERN_ALERT"TEST: (test2) exiting module MCF25!\n");
}

module_init(init_mcf25_cs);
module_exit(exit_mcf25_cs);

---- Makefile ----

CFLAGS += -Wall

obj-m += mcf25.o

mcf25-objs := mcf25_cs.o

---- Build output ----

make: Entering directory `/usr/src/linux-2.6.7'
CC [M] /home/john/test2/mcf25_cs.o
/home/john/test2/mcf25_cs.c: In function `init_mcf25_cs':
/home/john/test2/mcf25_cs.c:37: warning: implicit declaration of function `CardServices'
LD [M] /home/john/test2/mcf25.o
Building modules, stage 2.
MODPOST
*** Warning: "CardServices" [/home/john/test2/mcf25.ko] undefined!
CC /home/john/test2/mcf25.mod.o
LD [M] /home/john/test2/mcf25.ko
make: Leaving directory `/usr/src/linux-2.6.7'

--------------------------

foo_bar_foo 12-13-2004 03:23 PM

http://www.ecsl.cs.sunysb.edu/pub/ir...nts/dummy_cs.c

atticman 12-13-2004 03:35 PM

Thanks,
I have that already. I just stripped down my code for example purposes. My problem is getting the external references correct so I can build this against kernel 2.6.x. The second pass, MODPOST warnings are preventing the module from loading properly with the error:

insmod: error inserting 'mcf25.ko': -1 Unknown symbol in module

any help would be greatly appreciated!

-AM


All times are GMT -5. The time now is 08:41 AM.