[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Module loading - grub-emu, bug in kern/dl.c
From: |
Tomas Ebenlendr |
Subject: |
Module loading - grub-emu, bug in kern/dl.c |
Date: |
Tue, 21 Sep 2004 10:22:19 +0200 |
User-agent: |
Mutt/1.5.6i |
So I started to use solution no. 2 just to see if it really works. And
it doesn't! At least for normal.mod (fs modules are working well).
The problem is following:
$ readelf normal.mod:
...
Symbol table '.symtab' contains 88 entries:
Num: Value Size Type Bind Vis Ndx Name
...
26: 00000f13 370 FUNC GLOBAL DEFAULT 1 grub_command_execute
27: 00000000 0 NOTYPE GLOBAL DEFAULT UND grub_realloc
28: 00000004 24 OBJECT GLOBAL DEFAULT COM grub_exit_env
... ^^^
here is section index
COM == 65522, so it means some special section. (I don't understand elf
well), grub_dl_get_section_addr(mod, 65522) simply returns zero. Because
this is the only such symbol among all modules, this works at boottime,
where nothing wants the adress 0x4 (size 0x18). But this doesn't work in
grub_emu, because this address is unallocated.
If anyone have read and understands elf specification, please tell how
it should be fixed correctly. Otherwise I will learn how to fix it in
one month (maybe earlier).
>
> My current status is following: I can _load_ module (with same
> grub_arch_dl_relocate_symbols()),
> and with something similar to symlist.c). But I cannot execute it,
> because of i386 specific CFLAGS: -mregparm=3 -mrtd. (calling convetions)
> Posible solutions: 1) use another set of modules
> 2) don't use -mregparm=3 -mrtd
> 3) use __atribute__ ((regparm(3), stdcall)) for all
> functions that may be in modules.
>
> More detail on the third solution:
> int EXPORT_FUNC(foo) (int HOOK(*hook) (int))
> EXPORT_FUNC(x) will expand on HOOK(x), and HOOK(x) will expand on
> __atribute__ ((regparm(3), stdcall)) x
> when on i386.
> the hook should be also defined as follows:
> int HOOK(my_hook) (int argument) { body; }
> There can be special macros HOOK_A (and EXPORT_FUNC_A) for functions,
> that already have some __attribute__ (e.g., grub_fatal or grub_printf).
>
>
> I tried to do a wrapper (fourth solution), but that is impossible
> because of hooks. (They may originate in grub_emu as well as in module).
>
> PS.: We can distinguish between modules loadable in grub-emu, and
> boottime modules (and modules wich can be used both ways). I propose to
> have some flags (as variable or somewhere in elf header).
>
--
Tomas 'ebi' Ebenlendr
http://get.to/ebik
PF 2004.72244639876
- Re: normal mode chainloader, Marco Gerards, 2004/09/10
- Re: normal mode chainloader, Marco Gerards, 2004/09/12
- Re: normal mode chainloader, Tomas Ebenlendr, 2004/09/17
- Re: normal mode chainloader, M. Gerards, 2004/09/17
- Re: normal mode chainloader, Tomas Ebenlendr, 2004/09/17
- Re: normal mode chainloader, M. Gerards, 2004/09/17
- Re: normal mode chainloader, Tomas Ebenlendr, 2004/09/20
- Module loading - grub-emu, bug in kern/dl.c,
Tomas Ebenlendr <=