title: Building an out-of-tree Linux kernel modules which share object files with exported symbols
body: <p>Imagine a project, which needs to build two linux kernel modules, with the following layout of sources tree:</p>
  
  <pre><code>modules/
  |--common/
  |  `--common_data.c
  |--mod1/
  |  `--mod1_main.c
  `--mod2/
     `--mod2_main.c
  </code></pre>
  
  <p>The common_data.o object file needs to be included into both modules. So Kbuild file for this project looks something like this:</p>
  
  <pre><code>obj-m  := mod1.o mod2.o
  mod1-y := mod1/mod1_main.o common/common_data.o
  mod2-y := mod2/mod2_main.o common/common_data.o
  </code></pre>
  
  <p>It builds fine if there is not exported symbols (i.e. EXPORT_SYMBOL) in common_data.c file. But, if there are some exported symbols (e.g. <code>some_func</code>), then MODPOST will produce warnings like:</p>
  
  <pre><code>WARNING: mod2: 'some_func' exported twice. Previous export was in mod1.ko
  </code></pre>
  
  <p>This is because both modules share single Module.symvers file. It's possible to create two separate Kbuild files in mod1/ and mod2/ directories to avoid this warning, because then there will be two separate Module.symvers files. But this will lead to another issue - commond_data.o object will be built twice - first time when compiling mod1.ko and second time when compiling mod2.ko.</p>
  
  <p>Are there any ways to suppress this warning when using single Kbuild file or to prevent second rebuild of common_data.o file when using two separate Kbuild files?</p>