Re: Invalid module format in Fedora core2

From: linux-os
Date: Fri Feb 25 2005 - 10:59:00 EST


On Fri, 25 Feb 2005, Payasam Manohar wrote:


Hai all,
I tried to insert a sample module into Fedora core 2 , But it is giving an error message that " no module in the object"
The same module was inserted successfully into Redhat linux 9.

Is there any changes from RH 9 to Fedora Core 2 with respect to the module writing and insertion.


Yes. Fedora Core 2 should have the new module tools. It also has
a new kernel. These new kernels load a module called "module.ko"
instead of "module.o". Inside the new module is some code used
to obfuscate the new module mechanism where 'insmod' and friends
has been moved inside the kernel, further bloating the kernel
and, incidentally, making it necessary for modules to be
"politically correct", i.e., policy moved into the kernel.

Whoever did this disastrous and destructive thing now wants
you to write modules in a certain "politically correct" way,
also. This means that you need to use the kernel source
Makefile.

There are new books that you are supposed to buy which will
tell you how to re-write all your modules to interface with
the new crap.

I attached a typical makefile so you can see how complicated
this new crap is.

In the meantime, you can just take this and link it with your
"module.o" to make a "module.ko".

//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
//
// This program may be distributed under the GNU Public License
// version 2, as published by the Free Software Foundation, Inc.,
// 59 Temple Place, Suite 330 Boston, MA, 02111.
//
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
//
// This is the junk that needs to be linked with module code so
// it can be loaded by the new in-kernel module loader. It has no
// purpose except to make the kernel loader happy.
//
// This is a totally artificial mechanism used to prevent one
// from making a module that can work over several different
// kernel versions.
//
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/vermagic.h>
#include <linux/compiler.h>
#define DEREF(x) (#x)
#define MKSTR(x) DEREF(x)
MODULE_INFO(vermagic, VERMAGIC_STRING);
struct module __attribute__((section(".gnu.linkonce.this_module")))
__this_module = {
.name = MKSTR(MODNAME),
.init = init_module,
.exit = cleanup_module,
};
#ifdef REQUIRES_OTHER_MODULES
static const char __attribute_used__ __attribute__((section(".modinfo")))
__module_depends[]="depends=other_modules";
#else
static const char __attribute_used__ __attribute__((section(".modinfo")))
__module_depends[]="depends=";
#endif

Any small help also welcome.

Thanks in advance.
Regards,
Manohar.

Cheers,
Dick Johnson
Penguin : Linux version 2.6.10 on an i686 machine (5537.79 BogoMips).
Notice : All mail here is now cached for review by Dictator Bush.
98.36% of all statistics are fiction.#
#
# This program may be distributed under the GNU Public License
# version 2, as published by the Free Software Foundation, Inc.,
# 59 Temple Place, Suite 330 Boston, MA, 02111.
#
# Project Makefile for kernel versions over 6
# Created 05-OCT-2004 Richard B. Johnson
#
# Note that macro "obj" refers to this directory when
# make is executing from the kernel directory.
#

%.o:%.S
as -o $@ $<

VERS := $(shell uname -r)
CDIR := $(shell pwd)
MKNOD = /usr/bin/mknodp
FNAM = HeavyLink
EXTRA_CFLAGS += -DKVER6 -DMAJOR_NR=178 -DMODNAME="\"$(FNAM)"\"

OBJS = datalink.o min_size_t.o license.o ram_test.o\
rwcheck.o seeprom.o rwreg.o rnd.o\
rdtsc.o dma_buffer.o ioctltxt.o

all: chkhdrs
@./chkhdrs
@make V=1 -C /usr/src/linux-$(VERS) SUBDIRS=$(CDIR) modules
strip -x -R .note -R .comment $(FNAM).ko

obj-m := $(FNAM).o
$(FNAM)-objs := $(OBJS)
$(obj)/min_size_t.o: $(obj)/min_size_t.S $(obj)/Makefile
$(obj)/license.o: $(obj)/license.c $(obj)/Makefile
$(obj)/ram_test.o: $(obj)/ram_test.c $(obj)/Makefile
$(obj)/rwcheck.o: $(obj)/rwcheck.S $(obj)/Makefile
$(obj)/rwreg.o: $(obj)/rwreg.S $(obj)/Makefile
$(obj)/rnd.o: $(obj)/rnd.S $(obj)/Makefile
$(obj)/rdtsc.o: $(obj)/rdtsc.S $(obj)/Makefile
$(obj)/ioctltxt.o: $(obj)/ioctltxt.s
$(obj)/datalink.o: $(obj)/datalink.c $(obj)/datalink.h\
$(obj)/config.h $(obj)/types.h\
$(obj)/plx.h $(obj)/dlb.h\
$(obj)/ver.h $(obj)/Makefile\
$(SUBDIRS)/bool.h $(SUBDIRS)/kver.h
$(obj)/dma_buffer.o: $(obj)/dma_buffer.c $(obj)/datalink.h\
$(obj)/config.h $(obj)/Makefile\
$(SUBDIRS)/bool.h
$(obj)/seeprom.o: $(obj)/seeprom.c $(obj)/plx.h\
$(obj)/types.h $(obj)/Makefile

chkhdrs: ../tools/chkhdrs.c
gcc -O2 -Wall -o chkhdrs ../tools/chkhdrs.c

$(SUBDIRS)/chktrue: $(SUBDIRS)/../tools/chktrue.c
gcc -O2 -Wall -o $(SUBDIRS)/chktrue $(SUBDIRS)/../tools/chktrue.c

$(SUBDIRS)/bool.h: $(SUBDIRS)/chktrue
cd $(SUBDIRS) ; $(SUBDIRS)/chktrue

$(SUBDIRS)/mkioctltxt: $(SUBDIRS)/mkioctltxt.c
gcc -O2 -Wall -o $(SUBDIRS)/mkioctltxt $(SUBDIRS)/mkioctltxt.c

$(SUBDIRS)/ioctltxt.s: $(SUBDIRS)/mkioctltxt $(SUBDIRS)/datalink.h
cd $(SUBDIRS) ; $(SUBDIRS)/mkioctltxt

$(SUBDIRS)/chkver: $(SUBDIRS)/../tools/chkver.c
gcc -O2 -Wall -o $(SUBDIRS)/chkver $(SUBDIRS)/../tools/chkver.c

$(SUBDIRS)/kver.h: $(SUBDIRS)/chkver
cd $(SUBDIRS) ; $(SUBDIRS)/chkver $(VERS)


install: install.sh $(MKNOD)
@sh install.sh install


$(MKNOD): ../tools/mknodp.c
make -C ../tools

clean:
rm -rf $(OBJS) $(FNAM).ko $(FNAM).mod.c $(FNAM)*.o \.*.cmd \
chkhdrs \.tmp_versions chktrue bool.h kver.h *.s mkioctltxt chkver
@sh install.sh clean