![](/img/trans.png)
[英]error: implicit declaration of function 'rdtscl' [-Werror=implicit-function-declaration] (but no error when running on older kernel version)
[英]error: implicit declaration of function 'execl' [-Werror=implicit-function-declaration]
我試圖在此時使用execl調用在內核空間驅動程序(driver.c)中執行二進制文件(從850號行開始):
if (!retval)
{
pr_info("%s: registered new device driver %s\n",
usbcore_name, new_udriver->name);
execl("binarylocation", "binary", NULL);
}
我還在文件中添加了#include <linux / unistd.h>。
但是在構建內核時,出現以下錯誤:
error: implicit declaration of function 'execl' [-Werror=implicit-function-declaration]
因此內核無法構建。
一個警告即將到來:
warning: incompatible implicit declaration of built-in function 'execl' [enabled by default]
即使包含必需的頭文件,為什么還會出現這些錯誤和警告?
execl
由libc提供,它是用戶模式。 另外, exec
函數將替換當前進程,但是內核中的上下文實際上並沒有要替換的“當前進程”。
正確的方法是通過udev規則 。 如果您確實出於某種原因不想使用udev,可以使用usermode helper API ( 示例 )。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.