When compiling a kernel module, I got a WARNING with a note to add a compile option, CONFIG_DEBUG_SECTION_MISMATCH=y. It give me more detailed info about issue:
WARNING: \**\*path to module\***(.text+0x8d2): Section mismatch in reference from the function Pch_Spi_Enable_Bios_Wr() to the variable .devinit.data:ich9_pci_tbl.22939
The function Pch_Spi_Enable_Bios_Wr() references
the variable __devinitdata ich9_pci_tbl.22939.
This is often because Pch_Spi_Enable_Bios_Wr lacks a __devinitdata
annotation or the annotation of ich9_pci_tbl.22939 is wrong.
I could not find what exactly kernel section mismatch is, not to mention how to go about fixing it.
It means that a function that is in a section with a given lifetime references something that is in a section with a different lifetime.
When the kernel binary is linked, different parts of the code and data are split up into different sections. Some of these sections are kept loaded all the time, but some others are removed once they are no longer needed (things that are only required during boot for example can be freed once boot is done – this saves memory).
If a function that is in a long-lasting section refers to data in one of the discardable sections, there is a problem – it might try to access that data when it has already been released, leading to all kinds of runtime issues.
This is not a warning you’ll fix yourself, unless you wrote that code or are very familiar with it. It gets fixed by correctly annotating the function (or the data it refers to) so that it goes into the right section. The right fix can only be determined with detailed knowledge of that part of the kernel.
For a list of these sections and annotations, refer to the
include/linux/init.hheader in your kernel source tree:Others follow, with more comments and explanations.
See also the help text for the
CONFIG_DEBUG_SECTION_MISMATCHKconfig symbol: