Subject: Undefined references to `__umoddi3' and `__udivdi3'
From:Daniël W. Crompton <daniel.crompton@gmail.com>
Date: Sat, 31 Oct 2009 19:04:33 +0000
Sat, 31 Oct 2009 19:04:33 +0000
Happy Halloween,

I was getting a error (below) while compiling a new kernel, I found out that
a patch (also below) was required for linux/include/time.h as part of the
code is being optimized away losing the references.

I check the vserver mailing list and didn't see any post about this issue,
so I am posting it here so we now have a record of it.

Ciao,
Daniel


*ERROR:*
make bzImage
...
  LD      .tmp_vmlinux1
kernel/built-in.o: In function `getnstimeofday':
(.text+0x22bdc): undefined reference to `__umoddi3'
kernel/built-in.o: In function `getnstimeofday':
(.text+0x22bfc): undefined reference to `__udivdi3'
kernel/built-in.o: In function `do_gettimeofday':
(.text+0x22d0e): undefined reference to `__udivdi3'
kernel/built-in.o: In function `do_gettimeofday':
(.text+0x22d2c): undefined reference to `__umoddi3'
kernel/built-in.o: In function `timekeeping_resume':
timekeeping.c:(.text+0x22fd4): undefined reference to `__umoddi3'
timekeeping.c:(.text+0x22ff4): undefined reference to `__udivdi3'
kernel/built-in.o: In function `update_wall_time':
(.text+0x23306): undefined reference to `__umoddi3'
kernel/built-in.o: In function `update_wall_time':
(.text+0x23326): undefined reference to `__udivdi3'
kernel/built-in.o: In function `update_wall_time':
(.text+0x23796): undefined reference to `__umoddi3'
kernel/built-in.o: In function `update_wall_time':
(.text+0x237b6): undefined reference to `__udivdi3'
make: *** [.tmp_vmlinux1] Error 1



*PATCH:*

diff --git a/include/linux/time.h b/include/linux/time.h
index 2091a19..d32ef0a 100644
--- 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++;
 	}




blaze your trail

--
redhat

http://feeds.feedburner.com/GeneralMusing



Happy Halloween,

I was getting a error (below) while compiling a new kernel, I found out that a patch (also below) was required for linux/include/time.h as part of the code is being optimized away losing the references.

I check the vserver mailing list and didn't see any post about this issue, so I am posting it here so we now have a record of it.

Ciao,
Daniel


ERROR:
make bzImage
...
  LD      .tmp vmlinux1
kernel/built-in.o: In function `getnstimeofday':
(.text+0x22bdc): undefined reference to ` umoddi3'
kernel/built-in.o: In function `getnstimeofday':
(.text+0x22bfc): undefined reference to ` udivdi3'
kernel/built-in.o: In function `do gettimeofday':
(.text+0x22d0e): undefined reference to ` udivdi3'
kernel/built-in.o: In function `do gettimeofday':
(.text+0x22d2c): undefined reference to ` umoddi3'
kernel/built-in.o: In function `timekeeping resume':
timekeeping.c:(.text+0x22fd4): undefined reference to ` umoddi3'
timekeeping.c:(.text+0x22ff4): undefined reference to ` udivdi3'
kernel/built-in.o: In function `update wall time':
(.text+0x23306): undefined reference to ` umoddi3'
kernel/built-in.o: In function `update wall time':
(.text+0x23326): undefined reference to ` udivdi3'
kernel/built-in.o: In function `update wall time':
(.text+0x23796): undefined reference to ` umoddi3'
kernel/built-in.o: In function `update wall time':
(.text+0x237b6): undefined reference to ` udivdi3'
make: *** [.tmp vmlinux1] Error 1



PATCH:
diff --git a/include/linux/time.h b/include/linux/time.h
index 2091a19..d32ef0a 100644
--- 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++;
}



blaze your trail

--
redhat

http://feeds.feedburner.com/GeneralMusing