undefined reference to `__udivdi3'

Discuss usability issues, general maintenance, and general support issues for a grsecurity-enabled system.

undefined reference to `__udivdi3'

Postby akorn » Thu Jan 08, 2004 9:02 pm

I'm compiling on and for i386 and get the following message:

gcc -E -C -P -I/mnt/store/src/2.4.25/include -imacros /mnt/store/src/2.4.25/include/linux/config.h -imacros /mnt/store/src/2.4.25/include/asm-i386/segment.h -imacros /mnt/store/src/2.4.25/include/asm-i386/page_offset.h -Ui386 arch/i386/vmlinux.lds.S >arch/i386/vmlinux.lds
ld -m elf_i386 -T /mnt/store/src/2.4.25/arch/i386/vmlinux.lds -e stext arch/i386/kernel/head.o arch/i386/kernel/init_task.o init/main.o init/version.o init/do_mounts.o \
--start-group \
arch/i386/kernel/kernel.o arch/i386/mm/mm.o kernel/kernel.o mm/mm.o fs/fs.o ipc/ipc.o \
drivers/acpi/acpi.o drivers/char/char.o drivers/block/block.o drivers/misc/misc.o drivers/net/net.o drivers/net/wan/wan.o drivers/ide/idedriver.o drivers/cdrom/driver.o drivers/pci/driver.o drivers/video/video.o drivers/media/media.o drivers/md/mddev.o crypto/crypto.o \
net/network.o \
grsecurity/grsec.o \
/mnt/store/src/2.4.25/arch/i386/lib/lib.a /mnt/store/src/2.4.25/lib/lib.a /mnt/store/src/2.4.25/arch/i386/lib/lib.a \
--end-group \
-o vmlinux
grsecurity/grsec.o(.text+0x16706): In function `gr_acl_handle_psacct':
: undefined reference to `__udivdi3'
make[1]: *** [vmlinux] Error 1
make[1]: Leaving directory `/mnt/store/src/2.4.25'
make: *** [stamp-build] Error 2

This is 2.4.25-pre4 + grsec-2.0-rc4 + xfs, UML, iptables patch-o-matic and a couple of other small patches.

I tried with gcc-3.3 and 2.95..

I grepped the kernel source for 'udivdi3', and it's only found in some architectures; i386 is not among them. gr_acl_handle_psacct doesn't explicitly mention it, so it must probably come from a macro or something.

Any ideas welcome....
akorn
 
Posts: 8
Joined: Sat Dec 27, 2003 8:21 am

Re: undefined reference to `__udivdi3'

Postby PaX Team » Fri Jan 09, 2004 6:50 am

akorn wrote:I grepped the kernel source for 'udivdi3', and it's only found in some architectures; i386 is not among them. gr_acl_handle_psacct doesn't explicitly mention it, so it must probably come from a macro or something.
maybe http://forums.grsecurity.net/viewtopic.php?t=626&highlight=udivdi3 helps a bit.
PaX Team
 
Posts: 2310
Joined: Mon Mar 18, 2002 4:35 pm

Postby akorn » Fri Jan 09, 2004 9:09 am

OK, so if I back out the 64 bit jiffies patch, it should work. How can I make it work with the 64 bit jiffies left in?

What would the divisions I need to modify look like? What am I supposed to do with them?
akorn
 
Posts: 8
Joined: Sat Dec 27, 2003 8:21 am

Postby PaX Team » Fri Jan 09, 2004 10:06 am

akorn wrote:OK, so if I back out the 64 bit jiffies patch, it should work. How can I make it work with the 64 bit jiffies left in?

What would the divisions I need to modify look like? What am I supposed to do with them?
for a start, take a look at do_div() and its existing uses. note also that you will probably have to change more variables to 64 bits ('runtime' and maybe 'cputime' as well, check the program logic and see what can reasonably overflow in 32 bits).
PaX Team
 
Posts: 2310
Joined: Mon Mar 18, 2002 4:35 pm

Postby akorn » Fri Jan 09, 2004 4:45 pm

Ok, this is what I did:

Code: Select all
--- grsecurity/gracl.c  (revision 14)
+++ grsecurity/gracl.c  (working copy)
@@ -2708,8 +2708,9 @@
 void
 gr_acl_handle_psacct(struct task_struct *task, const long code)
 {
-       unsigned long runtime;
-       unsigned long cputime;
+       __u64 runtime;
+       __u64 cputime;
+       __u64 timetmp;
        unsigned int wday, cday;
        __u8 whr, chr;
        __u8 wmin, cmin;
@@ -2721,21 +2722,23 @@
                     !(task->acl->mode & GR_PROCACCT)))
                return;
 
-       runtime = (jiffies - task->start_time) / HZ;
-       wday = runtime / (3600 * 24);
+       timetmp = (jiffies - task->start_time);
+       runtime = do_div(timetmp, HZ);
+       wday = do_div(runtime, (3600 * 24));
        runtime -= wday * (3600 * 24);
-       whr = runtime / 3600;
+       whr = do_div(runtime, 3600);
        runtime -= whr * 3600;
-       wmin = runtime / 60;
+       wmin = do_div(runtime, 60);
        runtime -= wmin * 60;
        wsec = runtime;
 
-       cputime = (task->times.tms_utime + task->times.tms_stime) / HZ;
-       cday = cputime / (3600 * 24);
+       timetmp = (task->times.tms_utime + task->times.tms_stime);
+       cputime = do_div(timetmp, HZ);
+       cday = do_div(cputime, (3600 * 24));
        cputime -= cday * (3600 * 24);
-       chr = cputime / 3600;
+       chr = do_div(cputime, 3600);
        cputime -= chr * 3600;
-       cmin = cputime / 60;
+       cmin = do_div(cputime, 60);
        cputime -= cmin * 60;
        csec = cputime;


Does this look reasonably OK? It compiled, should I dare to boot? :)
akorn
 
Posts: 8
Joined: Sat Dec 27, 2003 8:21 am

Postby Sleight of Mind » Fri Jan 09, 2004 8:21 pm

i merged -ck with grsec and since 2.4.23-ck that series includes 64 bit jiffies, so you might want to take a look at that patch.
Sleight of Mind
 
Posts: 92
Joined: Tue Apr 08, 2003 10:41 am

Postby Sleight of Mind » Mon Jan 12, 2004 11:29 am

This is a patch containing the changes i made to grsec to have it work with 64 bit jiffies. Can anyone confirm these are correct? They do work (compile and run) but i'd like to make sure.
This is from 2.4.24-ck1-grsec, there is one more change in grsec (task_nice) but i'm sure that is correct, so its not in the file below.

http://deus.et.tudelft.nl/~sleight/grsec-jiff64.diff

Once i know these are correct i'll submit the grsec addon for 2.4.24-ck so everyone can use it.
Sleight of Mind
 
Posts: 92
Joined: Tue Apr 08, 2003 10:41 am


Return to grsecurity support