2007-09-07 13:24:40

by Johannes Berg

[permalink] [raw]
Subject: COMMON symbol warnings

After my compile run with __CHECK_ENDIAN__ the modules were built and I
got:

WARNING: "iwl_param_debug" [drivers/net/wireless/iwl3945] is COMMON symbol
WARNING: "iwl_param_disable_hw_scan" [drivers/net/wireless/iwl3945] is COMMON symbol
WARNING: "iwl_param_hwcrypto" [drivers/net/wireless/iwl3945] is COMMON symbol
WARNING: "iwl_param_antenna" [drivers/net/wireless/iwl3945] is COMMON symbol
WARNING: "iwl_param_disable" [drivers/net/wireless/iwl3945] is COMMON symbol
WARNING: "iwl_param_debug" [drivers/net/wireless/iwl4965] is COMMON symbol
WARNING: "iwl_param_disable_hw_scan" [drivers/net/wireless/iwl4965] is COMMON symbol
WARNING: "iwl_param_hwcrypto" [drivers/net/wireless/iwl4965] is COMMON symbol
WARNING: "iwl_param_antenna" [drivers/net/wireless/iwl4965] is COMMON symbol
WARNING: "iwl_param_disable" [drivers/net/wireless/iwl4965] is COMMON symbol
WARNING: "zd_workqueue" [drivers/net/wireless/zd1211rw-mac80211/zd1211rw-mac80211] is COMMON symbol
WARNING: "zd_workqueue" [drivers/net/wireless/zd1211rw/zd1211rw] is COMMON symbol

any idea what that means? It's from scripts/mod/modpost.c:
switch (sym->st_shndx) {
case SHN_COMMON:
warn("\"%s\" [%s] is COMMON symbol\n", symname, mod->name);
break;

johannes


Attachments:
signature.asc (190.00 B)
This is a digitally signed message part

2007-09-10 12:22:28

by Johannes Berg

[permalink] [raw]
Subject: Re: COMMON symbol warnings

On Mon, 2007-09-10 at 13:14 +0100, Christoph Hellwig wrote:

> No. Say you have the following case:
>
> ----------- foo.h ------------
> int foo;
> ----------- foo1.c -----------
> #include "foo.h"
> ----------- foo2.c -----------
> #include "foo.h"
> --------- Makefile -----------
> obj-m += foo.o
> foo-y += foo1.o foo2.o
>
>
> This gives you a foo COMMON symbol.

Ah, ok. I'm not familiar with these drivers though so I have no idea why
this happened, and then only with -D__CHECK_ENDIAN__.

> But at least on i386 the kernel
> is compiled with -fno-common so you get a warning like:

I'm building on powerpc. It has -fno-common as well.

> I wonder how the driver build managed to override our global -fno-common
> setting.

No idea. I guess the driver authors should look into it :)

johannes


Attachments:
signature.asc (190.00 B)
This is a digitally signed message part

2007-09-08 13:01:24

by Christoph Hellwig

[permalink] [raw]
Subject: Re: COMMON symbol warnings

On Thu, Sep 06, 2007 at 07:38:34PM +0200, Johannes Berg wrote:
> After my compile run with __CHECK_ENDIAN__ the modules were built and I
> got:
>
> WARNING: "iwl_param_debug" [drivers/net/wireless/iwl3945] is COMMON symbol
> WARNING: "iwl_param_disable_hw_scan" [drivers/net/wireless/iwl3945] is COMMON symbol
> WARNING: "iwl_param_hwcrypto" [drivers/net/wireless/iwl3945] is COMMON symbol
> WARNING: "iwl_param_antenna" [drivers/net/wireless/iwl3945] is COMMON symbol
> WARNING: "iwl_param_disable" [drivers/net/wireless/iwl3945] is COMMON symbol
> WARNING: "iwl_param_debug" [drivers/net/wireless/iwl4965] is COMMON symbol
> WARNING: "iwl_param_disable_hw_scan" [drivers/net/wireless/iwl4965] is COMMON symbol
> WARNING: "iwl_param_hwcrypto" [drivers/net/wireless/iwl4965] is COMMON symbol
> WARNING: "iwl_param_antenna" [drivers/net/wireless/iwl4965] is COMMON symbol
> WARNING: "iwl_param_disable" [drivers/net/wireless/iwl4965] is COMMON symbol
> WARNING: "zd_workqueue" [drivers/net/wireless/zd1211rw-mac80211/zd1211rw-mac80211] is COMMON symbol
> WARNING: "zd_workqueue" [drivers/net/wireless/zd1211rw/zd1211rw] is COMMON symbol
>
> any idea what that means?

Yes. It means a variable is declared in multiple places and the linker
merges it for you. The fix is to make sure these are declared extern in
all places but one.

2007-09-08 12:59:39

by Ulrich Kunitz

[permalink] [raw]
Subject: Re: COMMON symbol warnings

Johannes Berg wrote:

> After my compile run with __CHECK_ENDIAN__ the modules were built and I
...
> WARNING: "zd_workqueue" [drivers/net/wireless/zd1211rw-mac80211/zd1211rw-mac80211] is COMMON symbol
> WARNING: "zd_workqueue" [drivers/net/wireless/zd1211rw/zd1211rw] is COMMON symbol
>
> any idea what that means? It's from scripts/mod/modpost.c:
> switch (sym->st_shndx) {
> case SHN_COMMON:
> warn("\"%s\" [%s] is COMMON symbol\n", symname, mod->name);
> break;

It looks like that modpost warns about symbols that are shared
between objects. In the zd1211rw case this is a extern symbol
shared between objects, but this has never created an issue.
Surely one could write a function which returns the pointer to
prevent the warning, but I can't see the definite necessity.

--
Uli Kunitz

2007-09-08 16:35:36

by Michael Büsch

[permalink] [raw]
Subject: Re: COMMON symbol warnings

On Saturday 08 September 2007, Christoph Hellwig wrote:
> > WARNING: "zd_workqueue" [drivers/net/wireless/zd1211rw-mac80211/zd1211rw-mac80211] is COMMON symbol
> > WARNING: "zd_workqueue" [drivers/net/wireless/zd1211rw/zd1211rw] is COMMON symbol
> >
> > any idea what that means?
>
> Yes. It means a variable is declared in multiple places and the linker
> merges it for you. The fix is to make sure these are declared extern in
> all places but one.

Do you need an own workqueue in zd? Can you use the one mac80211 exports?


2007-09-09 08:50:45

by Ulrich Kunitz

[permalink] [raw]
Subject: Re: COMMON symbol warnings

Michael Buesch wrote:

> On Saturday 08 September 2007, Christoph Hellwig wrote:
> > > WARNING: "zd_workqueue" [drivers/net/wireless/zd1211rw-mac80211/zd1211rw-mac80211] is COMMON symbol
> > > WARNING: "zd_workqueue" [drivers/net/wireless/zd1211rw/zd1211rw] is COMMON symbol
> > >
> > > any idea what that means?
> >
> > Yes. It means a variable is declared in multiple places and the linker
> > merges it for you. The fix is to make sure these are declared extern in
> > all places but one.
>
> Do you need an own workqueue in zd? Can you use the one mac80211 exports?

We could use the one mac80211 exports. This has been on my TODO
list for quite some time. But given the other problems we still
have, this hasn't been the highest priority. There is no bug here,
the only issue is that resource usage is a little bit higher. The
warning is from my point of view useless, because it is always
shown regardless whether there is a problem or not.

--
Uli Kunitz

2007-09-10 11:06:41

by Johannes Berg

[permalink] [raw]
Subject: Re: COMMON symbol warnings

On Sat, 2007-09-08 at 14:01 +0100, Christoph Hellwig wrote:

> Yes. It means a variable is declared in multiple places and the linker
> merges it for you. The fix is to make sure these are declared extern in
> all places but one.

Interesting. So it's missing in a header file but sparse doesn't warn
about it like it does with functions that aren't declared nor static?

johannes


Attachments:
signature.asc (190.00 B)
This is a digitally signed message part

2007-09-10 12:14:13

by Christoph Hellwig

[permalink] [raw]
Subject: Re: COMMON symbol warnings

On Mon, Sep 10, 2007 at 01:08:12PM +0200, Johannes Berg wrote:
> On Sat, 2007-09-08 at 14:01 +0100, Christoph Hellwig wrote:
>
> > Yes. It means a variable is declared in multiple places and the linker
> > merges it for you. The fix is to make sure these are declared extern in
> > all places but one.
>
> Interesting. So it's missing in a header file but sparse doesn't warn
> about it like it does with functions that aren't declared nor static?

No. Say you have the following case:

----------- foo.h ------------
int foo;
----------- foo1.c -----------
#include "foo.h"
----------- foo2.c -----------
#include "foo.h"
--------- Makefile -----------
obj-m += foo.o
foo-y += foo1.o foo2.o


This gives you a foo COMMON symbol. But at least on i386 the kernel
is compiled with -fno-common so you get a warning like:

/home/hch/test/foo1.o:(.bss+0x0): multiple definition of `foo'
/home/hch/test/foo2.o:(.bss+0x0): first defined here

When adding -fcommon to EXTRA_FLAGS I get what you saw in this thread:

WARNING: "foo" [/home/hch/test/foo] is COMMON symbol

I wonder how the driver build managed to override our global -fno-common
setting.