zoukankan      html  css  js  c++  java
  • undefined reference to `__umoddi3'解决办法

    主机配置:ubuntu 11.10下利用交叉编译工具arm-linux-gcc编译内核;

    目标板:AT91SAM9260

    内核版本:linux-2.6.24


    在编译内核linux-2.6.24的过程中遇到错误:

    kernel/built-in.o: In function `getnstimeofday':
    utsname_sysctl.c:(.text+0x23c64): undefined reference to `__umoddi3'
    kernel/built-in.o: In function `do_gettimeofday':
    utsname_sysctl.c:(.text+0x23d18): undefined reference to `__udivdi3'
    utsname_sysctl.c:(.text+0x23d34): undefined reference to `__umoddi3'
    kernel/built-in.o: In function `timekeeping_resume':
    utsname_sysctl.c:(.text+0x23ec0): undefined reference to `__udivdi3'
    utsname_sysctl.c:(.text+0x23ee0): undefined reference to `__umoddi3'
    kernel/built-in.o: In function `update_wall_time':
    utsname_sysctl.c:(.text+0x24640): undefined reference to `__udivdi3'
    utsname_sysctl.c:(.text+0x24660): undefined reference to `__umoddi3'
    utsname_sysctl.c:(.text+0x246f4): undefined reference to `__udivdi3'
    utsname_sysctl.c:(.text+0x24714): undefined reference to `__umoddi3'
    make: *** [.tmp_vmlinux1] Error 1

    网上查阅了,说是include/linux/time.h文件中函数timespec_add_ns()的loop循环在编译过程中被优化掉了。

    static inline void timespec_add_ns(struct timespec *a, u64 ns)
    {
    	ns += a->tv_nsec;
    	while(unlikely(ns >= NSEC_PER_SEC)) {
    		ns -= NSEC_PER_SEC;
    		a->tv_sec++;
    	}
    	a->tv_nsec = ns;
    }
    利用https://lkml.org/lkml/2008/2/22/464的patch,可以解决这个问题。打上patch之后的函数是:

    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++;
    	}
    	a->tv_nsec = ns;
    }
    更改之后编译顺利通过。


  • 相关阅读:
    bzoj2733 永无乡 平衡树按秩合并
    bzoj2752 高速公路 线段树
    bzoj1052 覆盖问题 二分答案 dfs
    bzoj1584 打扫卫生 dp
    bzoj1854 游戏 二分图
    bzoj3316 JC loves Mkk 二分答案 单调队列
    bzoj3643 Phi的反函数 数学 搜索
    有一种恐怖,叫大爆搜
    BZOJ3566 概率充电器 概率dp
    一些奇奇怪怪的过题思路
  • 原文地址:https://www.cnblogs.com/java20130726/p/3218584.html
Copyright © 2011-2022 走看看