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


  • 相关阅读:
    Rust资料
    CMake & Ninja
    @Configurable
    Hibernate startup -> 配置SessionFactory实例
    Vue 渲染函数
    Spring 5 新特性
    @Configuration 注解的用途
    AOP
    AnnotationConfigApplicationContext.() -> Unit
    C编译优化
  • 原文地址:https://www.cnblogs.com/java20130726/p/3218584.html
Copyright © 2011-2022 走看看