Page 1 of 1

Executing Multiboot Module

Posted: Thu Mar 09, 2006 11:42 am
by KieranFoot
Hi guys, recently i have been playing with the use of multiboot modules for use with my kernel.

My problem is that im trying to execute the module, and i cant get it to run...

i have the module starting address from the mboot info structure, how do i execute the module code???

Do i use the multiboot header structure to read a header from the module start address to find the code offset???

Im confused... ??? :-[ ???

Re:Executing Multiboot Module

Posted: Thu Mar 09, 2006 12:22 pm
by nick8325
To GRUB, a multiboot module is just a file. It will gunzip it if it's compressed, but that's it. So GRUB won't look at the module at all, because it could be a program, but it could also be (for example) a configuration file or anything else.

So you'll need to know what format the modules that you're using as programs are, and write code to parse the headers yourself...

(P.S. if you don't need anything fancy, you could avoid having to parse something like ELF by linking modules as binary files with some very simple information - e.g. text/data size, BSS size, start address - in a start.s that will be the first few bytes of the file)

Re:Executing Multiboot Module

Posted: Thu Mar 09, 2006 4:03 pm
by KieranFoot
I found the elf32 format docs, the header gives me an entry of 0xf00000bf when the module is loaded at 0x10e000 and finishes at 0x110000, how can this be???

Re:Executing Multiboot Module

Posted: Fri Mar 10, 2006 4:15 am
by KieranFoot
No matter what type of header i use i get incorrect values, i know they are virtual values, but i dont understand how to use them or if im even reading the right memory...

The multiboot info block tells me my module was loaded at 0x10e000 so i point my header struct to that location

Code: Select all

modl = (krn_mod *)mod->start_adr;
i then read the header variables...

the modl->entry variable gives me 0x53f000ff
and so does the modl->x61 value (so called because its value should be 0x61616161)

I don't know what im doing wrong...

Re:Executing Multiboot Module

Posted: Fri Mar 10, 2006 5:51 am
by nick8325
I'm not sure...perhaps your struct could be wrong. Try printing out the first few values (or maybe all of them), and looking at your ELF in a hex editor, and seeing if they match up.

Also, make it print out the first few words of data without using the struct and see if that's what the hex editor shows.

Re:Executing Multiboot Module

Posted: Fri Mar 10, 2006 6:06 am
by KieranFoot
I have tried reading the data a few different ways, i get the same result no matter how i read the data.

This makes me thin that the pointer is incorrect...

Does anybody have an example of executing multiboot
modules, as such an example would be a great help...

Re:Executing Multiboot Module

Posted: Sat Mar 11, 2006 4:59 pm
by Pype.Clicker
well, i'd suggest the following items:
- try loading plain text first. See if that works.
- try opening and decoding an ELF file from your host system first (i mean, as a regular program).
- when everything seems okay, try to interprete ELF files loaded by GRUB. Note that there might be a couple of things to be done before the binary can actually be "executed", such as preparing virtual memory map according to the program requirements -- or relocating the executable if you opted for incremental linking.