Skip to contentSkip to conversation

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

PATCH In review Witold Baryluk 6 participants 12 messages Jun 2, 2012 – Jun 6, 2012

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

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.

Signature · 1 line
Witold Baryluk
#1 lore raw
Quoted 3 lines · Witold Baryluk

Hello everybody,

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

Hi Witold,

Thanks for the warnings.

Quoted 12 lines

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

Quoted 6 lines

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

Quoted 31 lines

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.

Signature · 1 line
Witold Baryluk
#2 lore raw
Quoted 10 lines · Don Zickus

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

Signature · 2 lines
H. Peter Anvin, Intel Open Source Technology Center
I work for Intel.  I don't speak on their behalf.
#3 lore raw
Quoted 8 lines · H. Peter Anvin
Quoted 7 lines · Don Zickus

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.

Quoted 5 lines
Quoted 3 lines

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

#4 lore raw
In reply to Don Zickus
Quoted 31 lines · Don Zickus
Quoted 3 lines · Witold Baryluk

Hello everybody,

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

Hi Witold,

Thanks for the warnings.

Quoted 12 lines

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

Quoted 6 lines

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.

Quoted 8 lines

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

#5 lore raw

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()

Quoted 41 lines · Sam Ravnborg
Quoted 31 lines · Don Zickus
Quoted 3 lines · Witold Baryluk

Hello everybody,

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

Hi Witold,

Thanks for the warnings.

Quoted 12 lines

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

Quoted 6 lines

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.

Quoted 8 lines

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.

Quoted 8 lines

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

Signature · 1 line
Witold Baryluk
#6 lore raw

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()

Quoted 17 lines

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
Quoted 4 lines

(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

#7 lore raw

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()

Quoted 25 lines
Quoted 2 lines

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()

Quoted 16 lines

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
Quoted 4 lines

(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).

Quoted 5 lines

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

Quoted 4 lines

--
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

#8 lore raw

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()

Quoted 4 lines

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

#9 lore raw

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()

Quoted 35 lines
Quoted 2 lines

However, fcoe_transport_exit() is called only in module *exit* path by

the

Quoted 1 line

module exit func libfcoe_exit(), not in the init_module error path. Let

me

Quoted 1 line

take a objdump of the libfcoe.o to see where your above section

mismatch warning

Quoted 1 line

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();     <==============
}
Quoted 4 lines

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

#10 lore raw

PATCH 1/1 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.

---
 drivers/scsi/fcoe/fcoe_transport.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/fcoe/fcoe_transport.c +1 -1
index b46f43d..71cc909 100644
@@ -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;
 
Acked-by on v1 1/1
#11 lore raw

Re: [PATCH] libfcoe: Fix section mismatch

Quoted 16 lines · Robert Love

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.

Quoted 2 lines

Looks good.

Sam