flat assembler
Message board for the users of flat assembler.
Index
> Linux > [SOLVED] Kernel modules in assembly (2.6.x) |
Author |
|
polygon7 03 Jun 2006, 18:00
Hi,
i tried to make ,,Hello world'' kernel module (for 2.6.x kernel). Code (based on ,,modul_dev_fasm'' by BogDro): Code: format ELF public init_module public cleanup_module extrn printk ;============================================================== section '.text' executable init_module: push ebx ecx edx esi push msg call printk add esp,4 xor eax, eax pop esi edx ecx ebx ret cleanup_module: ret ;============================================================= section '.data' writeable ; printk codes ; <0> Kernel Emergency ; <1> Kernel Alert ; <2> Kernel Critical Condition ; <3> Kernel Error ; <4> Kernel Warning ; <5> Kernel Notice ; <6> Kernel Info ; <7> Kernel Debug msg db "<1> Hello world!",10,0 ;============================================================= section '.modinfo' __module_kernel_version db "vermagic=2.6.17-beyond-git1 preempt mod_unload K7 REGPARM 4KSTACKS gcc-4.1", 0 __module_license db "license=GPL", 0 __module_author db "author=p7", 0 __module_description db "description=Hello World", 0 __module_depends db "depends=",0 But it doesn't work. hello_world# insmod ./hello_world.o shows: Quote: insmod: error inserting './hello_world.o': -1 Invalid module format syslogd shows: Quote: No module found in object Maybe someone know what is needed to make this module loaded? _________________ best regards p7 Last edited by polygon7 on 27 Aug 2006, 19:34; edited 1 time in total |
|||
03 Jun 2006, 18:00 |
|
polygon7 05 Jun 2006, 20:14
Feryno wrote: Years ago, I read article by mammon_ in asmjournal (apj_8) about loadable kernel modules and I tried it, but without success too. I know about mammon article, but his code don't work in 2.6.x. Kernel version is the same, so this is not that error. BogDro on Polish fasm forum says that there are some problems with makefiles and link stage. Modules, for example: some_module.ko, are maked from some_module.o files and some_module.mod.o files. But there is a question... how *.mod.o files are created (they are needed for correct module linking)? _________________ best regards p7 |
|||
05 Jun 2006, 20:14 |
|
scientica 11 Aug 2006, 10:57
iirc starting from 2.6.x the kernel uses a "new module format", you see the change inthe name, in the old days the moudles ended with .o, now they end in .ko (kernel object).
Afaik basically all "out side" modules invoke the kernel Makefile system with various options (ie nvidias driver compiles part of it self but also provides a binary blob (=the propitary part) which is simply linked in). I'd suggest you take a look at nvidias drivers (download the latest and run with "./NVIDIA-something -x" to extract the sfx (iirc, use '-h' if it doesn't work)) - they also show how to link in "external" objects (in nividia's case, source less files). Here's some info that might help (only scimmed thorugh them though) http://www.captain.at/programming/kernel-2.6/ http://www.tldp.org/LDP/lkmpg/2.6/html/x380.html http://linuxdevices.com/articles/AT4389927951.html |
|||
11 Aug 2006, 10:57 |
|
polygon7 11 Aug 2006, 11:13
scientica wrote: iirc starting from 2.6.x the kernel uses a "new module format", you see the change inthe name, in the old days the moudles ended with .o, now they end in .ko (kernel object). Thank you. _________________ best regards p7 |
|||
11 Aug 2006, 11:13 |
|
polygon7 27 Aug 2006, 19:33
Problem solved, BogDro makes 2.6 module in fasm
http://rudy.mif.pg.gda.pl/~bogdro/linux/sys_tut_linux.html#s04 _________________ best regards p7 |
|||
27 Aug 2006, 19:33 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.