2012-06-02 16:15:11

by Witold Baryluk

[permalink] [raw]
Subject: WARNING: arch/x86/built-in.o: Section mismatch in reference from the variable test_nmi_ipi_callback_na to function .ini.text:test_nmi_ipi_callback

Hello everybody,

x86 32-bit Build just got 2 WARNINGS when building kernel on Linus' tree.


VDSOSYM arch/x86/vdso/vdso32-syms.lds
LD arch/x86/vdso/built-in.o
LD arch/x86/built-in.o
WARNING: arch/x86/built-in.o(.data+0x5af0): Section mismatch in reference from the variable test_nmi_ipi_callback_na.10451 to the function .init.text:test_nmi_ipi_callback()
The variable test_nmi_ipi_callback_na.10451 references
the function __init test_nmi_ipi_callback()
If the reference is valid then annotate the
variable with __init* or __refdata (see linux/init.h) or name the variable:
*_template, *_timer, *_sht, *_ops, *_probe, *_probe_one, *_console

WARNING: arch/x86/built-in.o(.data+0x5b04): Section mismatch in reference from the variable nmi_unk_cb_na.10399 to the function .init.text:nmi_unk_cb()
The variable nmi_unk_cb_na.10399 references
the function __init nmi_unk_cb()
If the reference is valid then annotate the
variable with __init* or __refdata (see linux/init.h) or name the variable:
*_template, *_timer, *_sht, *_ops, *_probe, *_probe_one, *_console

LD vmlinux.o
MODPOST vmlinux.o
WARNING: vmlinux.o(.data+0x7cf0): Section mismatch in reference from the variable test_nmi_ipi_callback_na.10451 to the function .init.text:test_nmi_ipi_callback()
The variable test_nmi_ipi_callback_na.10451 references
the function __init test_nmi_ipi_callback()
If the reference is valid then annotate the
variable with __init* or __refdata (see linux/init.h) or name the variable:
*_template, *_timer, *_sht, *_ops, *_probe, *_probe_one, *_console

WARNING: vmlinux.o(.data+0x7d04): Section mismatch in reference from the variable nmi_unk_cb_na.10399 to the function .init.text:nmi_unk_cb()
The variable nmi_unk_cb_na.10399 references
the function __init nmi_unk_cb()
If the reference is valid then annotate the
variable with __init* or __refdata (see linux/init.h) or name the variable:
*_template, *_timer, *_sht, *_ops, *_probe, *_probe_one, *_console

GEN .version
CHK include/generated/compile.h




This is recent change.

gcc version 4.7.0 (Debian 4.7.0-11)

Debian sid, i386.

--
Witold Baryluk


2012-06-04 14:37:03

by Don Zickus

[permalink] [raw]
Subject: Re: WARNING: arch/x86/built-in.o: Section mismatch in reference from the variable test_nmi_ipi_callback_na to function .ini.text:test_nmi_ipi_callback

On Sat, Jun 02, 2012 at 06:15:02PM +0200, Witold Baryluk wrote:
> Hello everybody,
>
> x86 32-bit Build just got 2 WARNINGS when building kernel on Linus' tree.

Hi Witold,

Thanks for the warnings.

>
>
> VDSOSYM arch/x86/vdso/vdso32-syms.lds
> LD arch/x86/vdso/built-in.o
> LD arch/x86/built-in.o
> WARNING: arch/x86/built-in.o(.data+0x5af0): Section mismatch in reference from the variable test_nmi_ipi_callback_na.10451 to the function .init.text:test_nmi_ipi_callback()
> The variable test_nmi_ipi_callback_na.10451 references
> the function __init test_nmi_ipi_callback()
> If the reference is valid then annotate the
> variable with __init* or __refdata (see linux/init.h) or name the variable:
> *_template, *_timer, *_sht, *_ops, *_probe, *_probe_one, *_console
>
> WARNING: arch/x86/built-in.o(.data+0x5b04): Section mismatch in reference from the variable nmi_unk_cb_na.10399 to the function .init.text:nmi_unk_cb()
> The variable nmi_unk_cb_na.10399 references
> the function __init nmi_unk_cb()
> If the reference is valid then annotate the
> variable with __init* or __refdata (see linux/init.h) or name the variable:
> *_template, *_timer, *_sht, *_ops, *_probe, *_probe_one, *_console

These are intermediate variables test_nmi_ipi_callback_na.10451 and
nmi_unk_cb_na.10399. I do not know how to fix them.

Basically the test registers two nmi_handlers, run some tests, and
then unregisters them. Those handlers are what the compiler seems to be
complaining about. I do not know what magic to pass the compiler to let
it know that both of the handlers will be unregistered before the init
section is destroyed.

Perhaps I should tag those callbacks with __ref? I am not sure the right
thing to do here.

Cheers,
Don

>
> LD vmlinux.o
> MODPOST vmlinux.o
> WARNING: vmlinux.o(.data+0x7cf0): Section mismatch in reference from the variable test_nmi_ipi_callback_na.10451 to the function .init.text:test_nmi_ipi_callback()
> The variable test_nmi_ipi_callback_na.10451 references
> the function __init test_nmi_ipi_callback()
> If the reference is valid then annotate the
> variable with __init* or __refdata (see linux/init.h) or name the variable:
> *_template, *_timer, *_sht, *_ops, *_probe, *_probe_one, *_console
>
> WARNING: vmlinux.o(.data+0x7d04): Section mismatch in reference from the variable nmi_unk_cb_na.10399 to the function .init.text:nmi_unk_cb()
> The variable nmi_unk_cb_na.10399 references
> the function __init nmi_unk_cb()
> If the reference is valid then annotate the
> variable with __init* or __refdata (see linux/init.h) or name the variable:
> *_template, *_timer, *_sht, *_ops, *_probe, *_probe_one, *_console
>
> GEN .version
> CHK include/generated/compile.h
>
>
>
>
> This is recent change.
>
> gcc version 4.7.0 (Debian 4.7.0-11)
>
> Debian sid, i386.
>
> --
> Witold Baryluk

2012-06-04 15:00:04

by H. Peter Anvin

[permalink] [raw]
Subject: Re: WARNING: arch/x86/built-in.o: Section mismatch in reference from the variable test_nmi_ipi_callback_na to function .ini.text:test_nmi_ipi_callback

On 06/04/2012 07:36 AM, Don Zickus wrote:
>
> Basically the test registers two nmi_handlers, run some tests, and
> then unregisters them. Those handlers are what the compiler seems to be
> complaining about. I do not know what magic to pass the compiler to let
> it know that both of the handlers will be unregistered before the init
> section is destroyed.
>
> Perhaps I should tag those callbacks with __ref? I am not sure the right
> thing to do here.
>

Using __ref is the right thing, although __ref is hard to use right...

-hpa


--
H. Peter Anvin, Intel Open Source Technology Center
I work for Intel. I don't speak on their behalf.

2012-06-04 15:08:56

by Don Zickus

[permalink] [raw]
Subject: Re: WARNING: arch/x86/built-in.o: Section mismatch in reference from the variable test_nmi_ipi_callback_na to function .ini.text:test_nmi_ipi_callback

On Mon, Jun 04, 2012 at 07:59:41AM -0700, H. Peter Anvin wrote:
> On 06/04/2012 07:36 AM, Don Zickus wrote:
> >
> > Basically the test registers two nmi_handlers, run some tests, and
> > then unregisters them. Those handlers are what the compiler seems to be
> > complaining about. I do not know what magic to pass the compiler to let
> > it know that both of the handlers will be unregistered before the init
> > section is destroyed.
> >
> > Perhaps I should tag those callbacks with __ref? I am not sure the right
> > thing to do here.
> >
>
> Using __ref is the right thing, although __ref is hard to use right...

Thanks! I'll poke at it and see how lucky I get.

Cheers,
Don

2012-06-04 16:36:00

by Sam Ravnborg

[permalink] [raw]
Subject: Re: WARNING: arch/x86/built-in.o: Section mismatch in reference from the variable test_nmi_ipi_callback_na to function .ini.text:test_nmi_ipi_callback

On Mon, Jun 04, 2012 at 10:36:43AM -0400, Don Zickus wrote:
> On Sat, Jun 02, 2012 at 06:15:02PM +0200, Witold Baryluk wrote:
> > Hello everybody,
> >
> > x86 32-bit Build just got 2 WARNINGS when building kernel on Linus' tree.
>
> Hi Witold,
>
> Thanks for the warnings.
>
> >
> >
> > VDSOSYM arch/x86/vdso/vdso32-syms.lds
> > LD arch/x86/vdso/built-in.o
> > LD arch/x86/built-in.o
> > WARNING: arch/x86/built-in.o(.data+0x5af0): Section mismatch in reference from the variable test_nmi_ipi_callback_na.10451 to the function .init.text:test_nmi_ipi_callback()
> > The variable test_nmi_ipi_callback_na.10451 references
> > the function __init test_nmi_ipi_callback()
> > If the reference is valid then annotate the
> > variable with __init* or __refdata (see linux/init.h) or name the variable:
> > *_template, *_timer, *_sht, *_ops, *_probe, *_probe_one, *_console
> >
> > WARNING: arch/x86/built-in.o(.data+0x5b04): Section mismatch in reference from the variable nmi_unk_cb_na.10399 to the function .init.text:nmi_unk_cb()
> > The variable nmi_unk_cb_na.10399 references
> > the function __init nmi_unk_cb()
> > If the reference is valid then annotate the
> > variable with __init* or __refdata (see linux/init.h) or name the variable:
> > *_template, *_timer, *_sht, *_ops, *_probe, *_probe_one, *_console
>
> These are intermediate variables test_nmi_ipi_callback_na.10451 and
> nmi_unk_cb_na.10399. I do not know how to fix them.
>
> Basically the test registers two nmi_handlers, run some tests, and
> then unregisters them. Those handlers are what the compiler seems to be
> complaining about. I do not know what magic to pass the compiler to let
> it know that both of the handlers will be unregistered before the init
> section is destroyed.
>
> Perhaps I should tag those callbacks with __ref? I am not sure the right
> thing to do here.

Drop the __init from nmi_unk_cb() and test_nmi_ipi_callback().
Then the warnings are gone.

Trying to let register_nmi_handler() accept a function annotated __init is
wrong as we do not want this.
I someone try this in 'real' code we would be screwed.

Sam

2012-06-04 19:09:03

by Witold Baryluk

[permalink] [raw]
Subject: Different WARNING: drivers/scsi/fcoe/libfcoe.o(.init.text+0x1a): Section mismatch in reference from the function init_module() to the function .exit.text:fcoe_transport_exit()

On 06-04 18:35, Sam Ravnborg wrote:
> On Mon, Jun 04, 2012 at 10:36:43AM -0400, Don Zickus wrote:
> > On Sat, Jun 02, 2012 at 06:15:02PM +0200, Witold Baryluk wrote:
> > > Hello everybody,
> > >
> > > x86 32-bit Build just got 2 WARNINGS when building kernel on Linus' tree.
> >
> > Hi Witold,
> >
> > Thanks for the warnings.
> >
> > >
> > >
> > > VDSOSYM arch/x86/vdso/vdso32-syms.lds
> > > LD arch/x86/vdso/built-in.o
> > > LD arch/x86/built-in.o
> > > WARNING: arch/x86/built-in.o(.data+0x5af0): Section mismatch in reference from the variable test_nmi_ipi_callback_na.10451 to the function .init.text:test_nmi_ipi_callback()
> > > The variable test_nmi_ipi_callback_na.10451 references
> > > the function __init test_nmi_ipi_callback()
> > > If the reference is valid then annotate the
> > > variable with __init* or __refdata (see linux/init.h) or name the variable:
> > > *_template, *_timer, *_sht, *_ops, *_probe, *_probe_one, *_console
> > >
> > > WARNING: arch/x86/built-in.o(.data+0x5b04): Section mismatch in reference from the variable nmi_unk_cb_na.10399 to the function .init.text:nmi_unk_cb()
> > > The variable nmi_unk_cb_na.10399 references
> > > the function __init nmi_unk_cb()
> > > If the reference is valid then annotate the
> > > variable with __init* or __refdata (see linux/init.h) or name the variable:
> > > *_template, *_timer, *_sht, *_ops, *_probe, *_probe_one, *_console
> >
> > These are intermediate variables test_nmi_ipi_callback_na.10451 and
> > nmi_unk_cb_na.10399. I do not know how to fix them.
> >
> > Basically the test registers two nmi_handlers, run some tests, and
> > then unregisters them. Those handlers are what the compiler seems to be
> > complaining about. I do not know what magic to pass the compiler to let
> > it know that both of the handlers will be unregistered before the init
> > section is destroyed.
> >
> > Perhaps I should tag those callbacks with __ref? I am not sure the right
> > thing to do here.
>
> Drop the __init from nmi_unk_cb() and test_nmi_ipi_callback().
> Then the warnings are gone.
>
> Trying to let register_nmi_handler() accept a function annotated __init is
> wrong as we do not want this.
> I someone try this in 'real' code we would be screwed.
>
> Sam


By the way when we are on topic, here is one more


MKPIGGY arch/x86/boot/compressed/piggy.S
AS arch/x86/boot/compressed/piggy.o
LD arch/x86/boot/compressed/vmlinux
ZOFFSET arch/x86/boot/zoffset.h
AS arch/x86/boot/header.o
CC arch/x86/boot/version.o
LD arch/x86/boot/setup.elf
OBJCOPY arch/x86/boot/setup.bin
OBJCOPY arch/x86/boot/vmlinux.bin
BUILD arch/x86/boot/bzImage
Setup is 16288 bytes (padded to 16384 bytes).
System is 4418 kB
CRC 46186b65
Kernel: arch/x86/boot/bzImage is ready (#12)
Building modules, stage 2.
MODPOST 591 modules
WARNING: drivers/scsi/fcoe/libfcoe.o(.init.text+0x1a): Section mismatch in reference from the function init_module() to the function .exit.text:fcoe_transport_exit()
The function __init init_module() references
a function __exit fcoe_transport_exit().
This is often seen when error handling in the init function
uses functionality in the exit path.
The fix is often to remove the __exit annotation of
fcoe_transport_exit() so it may be used outside an exit section.

CC arch/x86/crypto/crc32c-intel.mod.o
LD [M] arch/x86/crypto/crc32c-intel.ko
CC arch/x86/crypto/salsa20-i586.mod.o
LD [M] arch/x86/crypto/salsa20-i586.ko
CC arch/x86/crypto/serpent-sse2-i586.mod.o
LD [M] arch/x86/crypto/serpent-sse2-i586.ko



(I'm dropping previous CC list, as this warning is easier to solve,
probably just following this instructions - dropping __exit from
fcoe_transport_exit() should be fine, especially if indeed it is needed
from init_module in error path).


Regards,
Witek

--
Witold Baryluk

2012-06-04 19:18:00

by Sam Ravnborg

[permalink] [raw]
Subject: Re: Different WARNING: drivers/scsi/fcoe/libfcoe.o(.init.text+0x1a): Section mismatch in reference from the function init_module() to the function .exit.text:fcoe_transport_exit()

> WARNING: drivers/scsi/fcoe/libfcoe.o(.init.text+0x1a): Section mismatch in reference from the function init_module() to the function .exit.text:fcoe_transport_exit()
> The function __init init_module() references
> a function __exit fcoe_transport_exit().
> This is often seen when error handling in the init function
> uses functionality in the exit path.
> The fix is often to remove the __exit annotation of
> fcoe_transport_exit() so it may be used outside an exit section.
>
> CC arch/x86/crypto/crc32c-intel.mod.o
> LD [M] arch/x86/crypto/crc32c-intel.ko
> CC arch/x86/crypto/salsa20-i586.mod.o
> LD [M] arch/x86/crypto/salsa20-i586.ko
> CC arch/x86/crypto/serpent-sse2-i586.mod.o
> LD [M] arch/x86/crypto/serpent-sse2-i586.ko
>
>
>
> (I'm dropping previous CC list, as this warning is easier to solve,
> probably just following this instructions - dropping __exit from
> fcoe_transport_exit() should be fine, especially if indeed it is needed
> from init_module in error path).

Correct - dropping __exit is the fix here.

Sam

2012-06-04 22:23:41

by Zou, Yi

[permalink] [raw]
Subject: RE: Different WARNING: drivers/scsi/fcoe/libfcoe.o(.init.text+0x1a): Section mismatch in reference from the function init_module() to the function .exit.text:fcoe_transport_exit()

>
> > WARNING: drivers/scsi/fcoe/libfcoe.o(.init.text+0x1a): Section mismatch
> in reference from the function init_module() to the
> function .exit.text:fcoe_transport_exit()
> > The function __init init_module() references
> > a function __exit fcoe_transport_exit().
> > This is often seen when error handling in the init function
> > uses functionality in the exit path.
> > The fix is often to remove the __exit annotation of
> > fcoe_transport_exit() so it may be used outside an exit section.
> >
> > CC arch/x86/crypto/crc32c-intel.mod.o
> > LD [M] arch/x86/crypto/crc32c-intel.ko
> > CC arch/x86/crypto/salsa20-i586.mod.o
> > LD [M] arch/x86/crypto/salsa20-i586.ko
> > CC arch/x86/crypto/serpent-sse2-i586.mod.o
> > LD [M] arch/x86/crypto/serpent-sse2-i586.ko
> >
> >
> >
> > (I'm dropping previous CC list, as this warning is easier to solve,
> > probably just following this instructions - dropping __exit from
> > fcoe_transport_exit() should be fine, especially if indeed it is needed
> > from init_module in error path).
>
> Correct - dropping __exit is the fix here.
>
> Sam

> Sam
However, fcoe_transport_exit() is called only in module *exit* path by the
module exit func libfcoe_exit(), not in the init_module error path. Let me
take a objdump of the libfcoe.o to see where your above section mismatch warning
is from. Is this on 32bit only?

yi

> --
> To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
> the body of a message to [email protected]
> More majordomo info at http://vger.kernel.org/majordomo-info.html

2012-06-04 22:33:45

by Sam Ravnborg

[permalink] [raw]
Subject: Re: Different WARNING: drivers/scsi/fcoe/libfcoe.o(.init.text+0x1a): Section mismatch in reference from the function init_module() to the function .exit.text:fcoe_transport_exit()

> However, fcoe_transport_exit() is called only in module *exit* path by the
> module exit func libfcoe_exit(), not in the init_module error path. Let me
> take a objdump of the libfcoe.o to see where your above section mismatch warning
> is from. Is this on 32bit only?

static int __init libfcoe_init(void)
{
int rc = 0;

rc = fcoe_transport_init();
if (rc)
return rc;

rc = fcoe_sysfs_setup();
if (rc)
fcoe_transport_exit(); <=============

return rc;
}

It is called from __init context here.




static void __exit libfcoe_exit(void)
{
fcoe_sysfs_teardown();
fcoe_transport_exit(); <==============
}

And from __exit context here.
This is -rc1.

Sam

2012-06-04 23:11:06

by Zou, Yi

[permalink] [raw]
Subject: RE: Different WARNING: drivers/scsi/fcoe/libfcoe.o(.init.text+0x1a): Section mismatch in reference from the function init_module() to the function .exit.text:fcoe_transport_exit()

>
> > However, fcoe_transport_exit() is called only in module *exit* path by
> the
> > module exit func libfcoe_exit(), not in the init_module error path. Let
> me
> > take a objdump of the libfcoe.o to see where your above section
> mismatch warning
> > is from. Is this on 32bit only?
>
> static int __init libfcoe_init(void)
> {
> int rc = 0;
>
> rc = fcoe_transport_init();
> if (rc)
> return rc;
>
> rc = fcoe_sysfs_setup();
> if (rc)
> fcoe_transport_exit(); <=============
>
> return rc;
> }
>
> It is called from __init context here.
>
>
>
>
> static void __exit libfcoe_exit(void)
> {
> fcoe_sysfs_teardown();
> fcoe_transport_exit(); <==============
> }
>
> And from __exit context here.
> This is -rc1.
>
> Sam
Ah...haven't pulled the rc1 yet, which was why I did not see the this.
Anyway, yeah you are right, dropping __exit should fix the problem.

thanks,
yi

2012-06-06 18:59:50

by Love, Robert W

[permalink] [raw]
Subject: [PATCH] libfcoe: Fix section mismatch

From: Mark Rustad <[email protected]>

Recent changes to add fcoe_sysfs caused libfcoe_init to call fcoe_transport_exit
in a module initialization routine. The change resulted in the below error. This
patch removes the __exit keyword from the fcoe_transport_exit definition such
that it may be called from an __init routine.

WARNING: drivers/scsi/fcoe/libfcoe.o(.init.text+0x21): Section mismatch in reference from the function init_module() to the function .exit.text:fcoe_transp
exit()
The function __init init_module() references
a function __exit fcoe_transport_exit().
This is often seen when error handling in the init function
uses functionality in the exit path.
The fix is often to remove the __exit annotation of
fcoe_transport_exit() so it may be used outside an exit section.

Signed-off-by: Mark Rustad <[email protected]>
Signed-off-by: Robert Love <[email protected]>
---
drivers/scsi/fcoe/fcoe_transport.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/fcoe/fcoe_transport.c b/drivers/scsi/fcoe/fcoe_transport.c
index b46f43d..71cc909 100644
--- a/drivers/scsi/fcoe/fcoe_transport.c
+++ b/drivers/scsi/fcoe/fcoe_transport.c
@@ -502,7 +502,7 @@ static int __init fcoe_transport_init(void)
return 0;
}

-static int __exit fcoe_transport_exit(void)
+static int fcoe_transport_exit(void)
{
struct fcoe_transport *ft;

2012-06-06 19:58:43

by Sam Ravnborg

[permalink] [raw]
Subject: Re: [PATCH] libfcoe: Fix section mismatch

On Wed, Jun 06, 2012 at 11:59:48AM -0700, Robert Love wrote:
> From: Mark Rustad <[email protected]>
>
> Recent changes to add fcoe_sysfs caused libfcoe_init to call fcoe_transport_exit
> in a module initialization routine. The change resulted in the below error. This
> patch removes the __exit keyword from the fcoe_transport_exit definition such
> that it may be called from an __init routine.
>
> WARNING: drivers/scsi/fcoe/libfcoe.o(.init.text+0x21): Section mismatch in reference from the function init_module() to the function .exit.text:fcoe_transp
> exit()
> The function __init init_module() references
> a function __exit fcoe_transport_exit().
> This is often seen when error handling in the init function
> uses functionality in the exit path.
> The fix is often to remove the __exit annotation of
> fcoe_transport_exit() so it may be used outside an exit section.
>
> Signed-off-by: Mark Rustad <[email protected]>
> Signed-off-by: Robert Love <[email protected]>

Looks good.

Acked-by: Sam Ravnborg <[email protected]>

Sam