Re: Undefined symbols in 2.6.11-rc5-mm1

From: Valdis . Kletnieks
Date: Wed Mar 02 2005 - 12:32:33 EST


On Wed, 02 Mar 2005 08:28:46 PST, Andrew Morton said:
> Adrian Bunk <bunk@xxxxxxxxx> wrote:

> > Why doesn't an EXPORT_SYMBOL create a reference?
>
> It does, but that reference is within the same compilation unit as the
> definition. IOW: there are no references to the symbol which are external
> to the symbol's file. There's still nothing to drag that file in.

I just got bit by a similar issue myself last night. Had a working 2.6.11-rc5-mm1 tree
compiled with gcc 3.4. Then Fedora-devel had an update to gcc 4.0, so I
rebuilt the *same exact tree* with it, and it threw 3 errors at me, for
exit_orinoco() in drivers/net/wireless/orinoco.c and init_hermes() and exit_hermes()
in drivers/net/wireless/hermes.c. Here's what the code looked like:

(hermes.c)
static int __init init_hermes(void)
{
return 0;
}

static void __exit exit_hermes(void)
{
}

module_init(init_hermes);
module_exit(exit_hermes);

That's it. As far as I can tell, gcc 4.0 semi-correctly determined they were both
static functions with no side effect, threw them away, and then the module_init
and module_exit threw undefined symbols for them.

My totally incorrect workaround was to stick a printk(KERN_DEBUG) in the body
of the 3 trimmed functions so they had side effects.

Anybody got a *better* solution?

Attachment: pgp00000.pgp
Description: PGP signature