问题
I am using the google ndk toolchain to cross compile an image for my Samsung Note 3 SM-N900P model. I downloaded the Kitkat version of Samsung Source code, and believe I have followed the instructions in the Kernel Readme file. It stated to use 4.7 toolchain, and I found it in NDK version 8d. But I get the following error:
ERROR: modpost: Found 2 section mismatch(es).
To see full details build your kernel with:
'make CONFIG_DEBUG_SECTION_MISMATCH=y'
To build the kernel despite the mismatches, build with:
'make CONFIG_NO_ERROR_ON_MISMATCH=y'
(NOTE: This is not recommended)
/home/sansari/android/kernel/scripts/Makefile.modpost:98: recipe for target 'vmlinux.o' failed
make[1]: *** [vmlinux.o] Error 1
Makefile:935: recipe for target 'vmlinux.o' failed
make: *** [vmlinux.o] Error
After doing some searching online, I see two different posts hereand here. One seems to imply that I can not fix the issue, while the other says somewhat the opposite. This is based on my limited knowledge of the make file. I have basically read the first three chapters of the user's guide. I know what recepies are, and what it's basic structure is. I did look at line 935 of my Makefile and Here it is:
modpost-init := $(filter-out init/built-in.o, $(vmlinux-init))
vmlinux.o: $(modpost-init) $(vmlinux-main) FORCE
$(call if_changed_rule,vmlinux-modpost)
I am posting this to find out if I can fix this error, and how I should go about it. Can anyone provide advice on how involved this problem is? Is it something I can fix?
Here is the error when make debug option is turned on:
WARNING: vmlinux.o(.data+0x8434): Section mismatch in reference from the variable msm_mpm_debug_mask to the function .init.text:mpm_irq_domain_linear_size()
The variable msm_mpm_debug_mask references
the function __init mpm_irq_domain_linear_size()
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+0x844c): Section mismatch in reference from the variable msm_mpm_debug_mask to the function .init.text:mpm_irq_domain_legacy_size()
The variable msm_mpm_debug_mask references
the function __init mpm_irq_domain_legacy_size()
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
To build the kernel despite the mismatches, build with:
'make CONFIG_NO_ERROR_ON_MISMATCH=y'
(NOTE: This is not recommended)
/home/sansari/android/kernel/scripts/Makefile.modpost:98: recipe for target 'vmlinux.o' failed
make[1]: *** [vmlinux.o] Error 1
Makefile:935: recipe for target 'vmlinux.o' failed
make: *** [vmlinux.o] Error 2
回答1:
Use 4.7, or if 4.8 try starting make with this:
make -j$NUMBEROFCPUS CONFIG_NO_ERROR_ON_MISMATCH=y
for example on Nexus 5 I build with
make -j$NUMBEROFCPUS CONFIG_NO_ERROR_ON_MISMATCH=y zImage-dtb
来源:https://stackoverflow.com/questions/27698976/how-to-fix-section-mismatch-errors-during-cross-compile-of-android