bugGNU GRUB - Bugs: bug #22750, broken module init

 
 

You are not allowed to post comments on this tracker with your current authentication level.

bug #22750: broken module init

Submitter:  Alexander Zubkov <zubkov>
Submitted:  Thu 27 Mar 2008 09:21:25 AM UTC
   
 
Category:  None Severity:  Major
Priority:  5 - Normal Item Group:  Software Error
Status:  Invalid Privacy:  Public
Assigned to:  None Originator Name: 
Open/Closed:  Closed Release:  None
Release:  1.96 Reproducibility:  Every Time
Planned Release:  None

Thu 14 Aug 2008 02:59:31 PM UTC, comment #4: 

I wonder why this bug report is still open if it was the fault of gentoo.

Felix Zielcke <fzielcke>
Group Member
Thu 27 Mar 2008 11:29:17 AM UTC, comment #3: 

I was wrong. It is not the grub2 fault. It is broken Gentoo's ebuild. They forget to disable stripping! Thank You for pointing me the right direction. Bug can be closed.

Alexander Zubkov <zubkov>
Thu 27 Mar 2008 10:12:33 AM UTC, comment #2: 

I'm sorry i get confused. In fact, grub_mod_init is defined in biosdisk.c. GRUB_MOD_INIT will expand to:

static void grub_mod_init (grub_dl_t mod _attribute_ ((unused))) _attribute_ ((used));

void grub_biosdisk_init (void);

void grub_biosdisk_init (void) { grub_mod_init (0); }

static void grub_mod_init (grub_dl_t mod _attribute_ ((unused)))
{
 // INIT function
}

grub_mod_init is private so that it won't conflict with other module, but it's stored in the object file, you can verify it with nm:

nm biosdisk.mod

mod-biosdisk.c is used to put the module name and dependence in the output file, so that the loader can load them automatically.

Bean <bean>
Thu 27 Mar 2008 09:41:32 AM UTC, comment #1: 

I think you misunderstand the way grub module works. In fact, the build script will generate a trunk file mod-biosdisk.c with the following content:

#include <grub/dl.h>

GRUB_MOD_NAME(biosdisk);

grub_mod_init is defined in this file.


Bean <bean>
Thu 27 Mar 2008 09:21:25 AM UTC, original submission:  

Several days I was trying to make grub2 work on my server. It seems that it cannot see bios disk for some reason. Using debug print I found this. Let's look at biosdisk module source, for example:

disk/i386/pc/biosdisk.c:



GRUB_MOD_INIT(biosdisk)
{
...


This is begin of definition of init function of module.
Next, look at definition of GRUB_MOD_INIT macro:

include/grub/dl.h:


#define GRUB_MOD_INIT(name) \
static void grub_mod_init (grub_dl_t mod _attribute_ ((unused))) _attribute_ ((used)); \
void grub_##name##_init (void); \
void \
grub_##name##_init (void) { grub_mod_init (0); } \
static void \
grub_mod_init (grub_dl_t mod _attribute_ ((unused)))


As we see it will make exported function grub_biosdisk_init. And finally, let's see at module loading procedure:

kern/dl.c:


if (grub_strcmp (name, "grub_mod_init") == 0)
  mod->init = (void (*) (grub_dl_t)) sym->st_value;


Here we see, that init function of a module is expecting grub_mod_init and so it remains nil and not run at all.

May be I mistakes about this symbol mesh, but inserted debug print showed that: module init function doesn't get called, biosdisk exports only grub_biosdisk_fini and grub_biosdisk_init and no grub_mod_init.

For the case if I have really broken compiler or system, here is some info:
CPU Intel Xeon 3060
gcc version 4.1.2, target x86_64-pc-linux-gnu

Alexander Zubkov <zubkov>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by fzielcke (Posted a comment)
  • -email is unavailable- added by bean (Posted a comment)
  • -email is unavailable- added by zubkov (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

     

    Follow 2 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2008-08-14 fzielcke StatusNone Invalid
        Open/ClosedOpen Closed

    Back to the top

    Powered by Savane 3.13-02a9.
    Corresponding source code