如何在内核编译期间纠正错误“未定义的__mutex_lock_slowpath引用”?

时间:2013-07-17 05:23:43

标签: linux-kernel

我正在Ubuntu 12.04上编译内核版本2.6.25。当我使用“make”命令编译它时。

我收到错误:

kernel / built-in.o:在函数`mutex_lock'中:

/usr/src/linux-2.6.25/kernel/mutex.c:92:对__mutex_lock_slowpath'的未定义引用

kernel / built-in.o:在函数`mutex_unlock'中:

/usr/src/linux-2.6.25/kernel/mutex.c:117:对__mutex_unlock_slowpath'的未定义引用

make: * [.tmp_vmlinux1]错误1

如何纠正这些错误?请帮忙

2 个答案:

答案 0 :(得分:1)

原来解决方案是在四个位置更改kernel/mutex.c

第60,96,192行

-static void fastcall noinline __sched
+static __attribute__ ((used)) void fastcall noinline __sched

第251行

-static fastcall noinline void
+static __attribute__ ((used)) void fastcall noinline __sched

我不知道为什么__used无法正常工作。

答案 1 :(得分:0)

更改kernel / mutex.c中的声明应该足以强制将函数保留在目标文件中。您可以使用gcc属性扩展名" __ used"像这样:

-static void noinline __sched
+static __used void noinline __sched
 __mutex_lock_slowpath(atomic_t *lock_count);

-static noinline void __sched __mutex_unlock_slowpath(atomic_t *lock_count);
+static __used noinline void __sched __mutex_unlock_slowpath(atomic_t *lock_count);