FATAL: modpost: Section mismatches detected错误解决

如题,写完驱动后编译内核的时候碰到了这个错误,头一次看到这个编译错误,略懵逼,先给出完整的错误:

WARNING: modpost: Found 2 section mismatch(es).
To see full details build your kernel with:
'make CONFIG_DEBUG_SECTION_MISMATCH=y'
FATAL: modpost: Section mismatches detected.
Set CONFIG_SECTION_MISMATCH_WARN_ONLY=y to allow them.

根据提示,加上编译选项“CONFIG_DEBUG_SECTION_MISMATCH=y”后可以看到详细的错误地方,然后就能看到下面的错误:

WARNING: drivers/misc/mediatek/built-in.o(.data+0x56ec): Section mismatch in reference from the variable aht10_init_info to the function .init.text:aht10_local_init()
The variable aht10_init_info references
the function __init aht10_local_init()
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

如果看到这个提示还不懂什么意思的话,可以看看这篇文章:What is kernel section mismatch?。结合文章,意思就是变量aht10_init_info引用了__init aht10_local_init函数,因为函数用__init修饰后,会在执行完就释放函数所占用的内存,那么aht10_init_info再引用__init aht10_local_init函数就是非法的了,我们看一下两者的关系:

static struct hmdy_init_info aht10_init_info = {
		.name = "aht10",
		.init = aht10_local_init,
		.uninit = aht10_local_uninit,
	
};

static __init int aht10_local_init(void)
{
    ...
	return 0;
}

所以想解决这个问题,我们将函数的__init修饰符去掉就好:

static int aht10_local_init(void)
{
    ...
	return 0;
}

 

  • 1
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
引用: 在Linux中,当使用Git操作时,有时会出现"fatal: detected dubious ownership"的错误提示。这个错误提示表示Git检测到了仓库所属者的不确定性。这可能是由于文件或目录的所有者与当前用户不匹配所引起的。 要解决这个问题,可以尝试以下方法: 1. 使用chown命令更改文件或目录的所有者。例如,如果你的仓库位于"/path/to/repository",你可以使用以下命令将其所有者更改为当前用户: ``` sudo chown -R <current_user> /path/to/repository ``` 其中"<current_user>"是你当前的用户名。 2. 如果你无法使用chown命令,可以尝试使用git config命令来添加异常目录。例如,如果你的仓库位于"/path/to/repository",你可以使用以下命令添加异常目录: ``` git config --global --add safe.directory /path/to/repository ``` 这将向Git配置文件中添加一个安全目录,使Git不再检测该目录的所有权。 需要注意的是,以上方法适用于Linux系统。如果你在Windows系统上遇到类似的问题,可以尝试相应的解决方法。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* [Windows平台的 PHP 报错 Fatal error: Class COM not found in 的解决方法](https://download.csdn.net/download/weixin_38723461/12902954)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] - *2* *3* [fatal: detected dubious ownership in repository(已解决)](https://blog.csdn.net/Ericjim/article/details/129180708)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值