Author Topic: LKMs (linux modules) with nasm don't work  (Read 40511 times)

Offline Cyrill Gorcunov

  • NASM Developer
  • Full Member
  • *****
  • Posts: 179
  • Country: 00
Re: LKMs (linux modules) with nasm don't work
« Reply #30 on: July 26, 2010, 09:58:05 PM »
no, no common section for the elf at the moment iirc. use "global" and keywords as "function" and please read documentation as well, for example, note section "9.2.4 Exporting Symbols to the Library User".

Quote
Also into loaded libraries or like this example here shows - the need to link into the running kernel for module load.

it will NOT help, i tired to repeat -- module requires predefined structure for "linkonce" section.
Frankly, use C for such cases and nasm for core functions this will eliminate all your problems.

Offline Cyrill Gorcunov

  • NASM Developer
  • Full Member
  • *****
  • Posts: 179
  • Country: 00
Re: LKMs (linux modules) with nasm don't work
« Reply #31 on: July 26, 2010, 09:59:12 PM »
we have COMMON directive but it's not what you meant I guess.

Offline bastl

  • Jr. Member
  • *
  • Posts: 17
Re: LKMs (linux modules) with nasm don't work
« Reply #32 on: July 27, 2010, 03:41:55 PM »
we have COMMON directive but it's not what you meant I guess.
Surely, I did read the documentation and COMMON declaration was the only thing that does what I need (in elf)  but it should be used for all symbols not only for symbols of variables.

All symbols in the running environment have to be overwritten !!!
So all symbols and its offsets are unique and equal  in the running environment


And why not use COMMON as a directive to all symbols in NASM (elf) ? Would be nice to have full support of elf in NASM, or not?

« Last Edit: July 27, 2010, 03:46:42 PM by bastl »

Offline Cyrill Gorcunov

  • NASM Developer
  • Full Member
  • *****
  • Posts: 179
  • Country: 00
Re: LKMs (linux modules) with nasm don't work
« Reply #33 on: July 27, 2010, 05:14:29 PM »
SHN_COMMON has nothing to do with this particular "kernel modules" problem.

So if you need SHN_COMMON not for variables but for functions names as well then I guess we may take a look and check how much effort it will require to bring this ability in.

Actually better to ping us via bugtracker then -- there is "Feature request" category when you describes what you need and why. So we get notified that there some new request.

See http://nasm.us/ for "Bug Tracker" on top menu and fill request please.

Offline hoverlees

  • New Member
  • Posts: 1
Re: LKMs (linux modules) with nasm don't work
« Reply #34 on: August 02, 2010, 10:32:37 AM »
Why can't I programm LKMs with nasm? (they won't load)

I think because of a bigger BSS section than given ( the "nasm - version" string).

Is there any possibility to void this string ?

Hello bastl, what is your linux kernel version? Your code seems only fit for linux2.4, My linux 2.6 insmod the driver  cause a  "Invalid module format" problem .
What ashamed I havent successfully compiled a linux2.6 kernel module by nasm
« Last Edit: August 02, 2010, 10:41:44 AM by hoverlees »

Offline bastl

  • Jr. Member
  • *
  • Posts: 17
Re: LKMs (linux modules) with nasm don't work
« Reply #35 on: August 02, 2010, 07:31:06 PM »
Hello bastl, what is your linux kernel version? Your code seems only fit for linux2.4, My linux 2.6 insmod the driver  cause a  "Invalid module format" problem .
What ashamed I havent successfully compiled a linux2.6 kernel module by nasm

My linux kernel is 2.6.26.2.
I have a glibc, binutils GNU system.
The 2.6 kernel module loader is more flexible as the 2.4 one.
It all depends on which linker you build the kernel for/with. In the case you want to load the last given simple example above, you need a kernel builded with the gnu binutils ld linker.