Linux内核编译错误: undefined reference to `__udivdi3' & `__umoddi3'

标签 linux kernel

这是我遇到的错误: http://pastebin.com/VadUW6fy

drivers/built-in.o: In function `gem_rxmac_reset':
clkdev.c:(.text+0x212238): undefined reference to `__bad_udelay'
drivers/built-in.o: In function `divide.part.4':
clkdev.c:(.text.unlikely+0x7214): undefined reference to `__udivdi3'
clkdev.c:(.text.unlikely+0x7244): undefined reference to `__umoddi3'

我用谷歌搜索并找到了这个补丁:https://lkml.org/lkml/2008/4/7/82

--- a/include/linux/time.h
+++ b/include/linux/time.h
@@ -174,6 +174,10 @@ static inline void timespec_add_ns(struct timespec *a, u64 ns)
 {
        ns += a->tv_nsec;
        while(unlikely(ns >= NSEC_PER_SEC)) {
+               /* The following asm() prevents the compiler from
+                * optimising this loop into a modulo operation.  */
+               asm("" : "+r"(ns));
+
                ns -= NSEC_PER_SEC;
                a->tv_sec++;
        }

但申请失败(可能是文件的新版本)

     patching file linux/time.h
     Hunk #1 FAILED at 174.
     1 out of 1 hunk FAILED -- saving rejects to file linux/time.h.rej

令人惊讶的是,文件 time.h.rej 不存在!

最佳答案

我应该更仔细地阅读。该补丁适用于 timespec_add_ns(),并且您有 gem_rxmac_reset()divide.part.4 函数失败。可能与您找到的补丁无关——相反,标准的 64 位 div/mod 函数可能在您的目标平台上没有实现。

您有 Sun GEM 或 Apple GMAC NIC 吗?如果没有,您可能只需禁用该驱动程序并摆脱第一条错误消息。

对于第二个,您可能需要在 clkdev.c 文件中实现类似的 asm 技巧——当我浏览我的副本以进行重复的减法操作时,我没有没有发现 - 但也许您可以简单地窃取更新的 clkdev.cclkdev.h 来解决这个问题? (不太可能,git log drivers/clk/clkdev.c 中只有 一个 条目。)

关于Linux内核编译错误: undefined reference to `__udivdi3' & `__umoddi3' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8374969/

相关文章:

c - 在内核中使用 sock_create、accept、bind 等

macos - 如何在 macosx 内核中获取特定进程的虚拟地址的物理地址?

我可以在多线程(pthreads)应用程序中捕获 SIGSEGV 和其他信号并打印导致它的线程或所有线程的回溯吗?

java - 使用 eclipse 在 Windows 上运行 .sh(来自 linux)脚本

c# - 如何在WinDBG中分析内核转储

docker - 自定义 boot2docker.iso 以在容器上使用无线设备(Docker-toolbox)

c - 在单个管道中进行多次读写

linux - 如何检查用户是否登录了更多天?

linux - 统计目录下所有gzip文件的字节数

c++ - 如何使用 GRUB 查询 BIOS?