WARNING: modpost: Found 10 section mismatch(es)

6,287

Pure copy from this SO Q&A, A solution to this question is of valuable to U&L as well!

Reference


This is just a warning. The kernel build systems did a sanity check and found out something that might be an error. The warning message says somewhere in kernel code there is code that might do inappropriate cross section access. Note that your kernel did build!

To understand what the warning means, consider the following example:

Some kernel code in the kernel text section might be trying to call a function marked with the __init data macro, which the linker puts in the kernel init section that gets de-allocated after boot or module loading.

This might be a run time error since if the code in the text section calls the code in the init section after the initialization code has finished, it is basically calling a stale pointer.

Having said that, that call may be perfectly fine - it is possible that the calls in the kernel text section has some good reason to know that it only calls the function in the init section when it is guaranteed to be there.

This, of course, is just an example. Similar other scenarios also exists.

The solution is to compile with CONFIG_DEBUG_SECTION_MISMATCH=y which will give you output of what function is trying to access which data or function and which section they belong to. You can then try to figure out if the build time warning is warranted and if so hopefully fix.

The init.h macros __ref and __refdata can be used to allow such init references without warnings. For example,

char * __init_refok bar(void) 
{
  static int flag = 0;
  static char* rval = NULL;
  if(!flag) {
     flag = 1;
     rval = init_fn(); /* a function discarded after init */
  }
  return rval;
}

__init_refok, etc can fix "valid" instances, so the fact they exist may not inspire confidence.

Share:
6,287

Related videos on Youtube

Aquarius_Girl
Author by

Aquarius_Girl

Arts and Crafts.stackexchange.com is in public beta now. Join us!

Updated on September 18, 2022

Comments

  • Aquarius_Girl
    Aquarius_Girl over 1 year

    Is this error message something that I should be worried about?

    linux-y3pi:/usr/src/linux-2.6.38.8 # make modules
    scripts/kconfig/conf --silentoldconfig Kconfig
      CHK     include/linux/version.h
      CHK     include/generated/utsrelease.h
      CALL    scripts/checksyscalls.sh
      Building modules, stage 2.
      MODPOST 2516 modules
    ***WARNING: modpost: Found 10 section mismatch(es).***
    To see full details build your kernel with:
    'make CONFIG_DEBUG_SECTION_MISMATCH=y'
    
    • sunnysideup
      sunnysideup almost 12 years
    • user2136106
      user2136106 almost 12 years
      @UlrichDangel That's very good answer for this question, but how to handle this question? Close it for duplicated or Leave it as a high voted unanswered question(4 votes is high in unix.SE) or somethings else?
    • Aquarius_Girl
      Aquarius_Girl almost 12 years
      @LaiJiangshan Or merge that answer with this one?