Compiling a kernel module on 32-Bit Linux kernel results in
"__udivdi3" [mymodule.ko] undefined!
"__umoddi3" [mymodule.ko] undefined!
Everything is fine on 64-bit systems. As far as I know, the reason for this is that 64-bit integer division and modulo are not supported inside a 32-bit Linux kernel.
How can I find the code issuing the 64-bit operations. They are hard to find manually because I cannot easily check if an “/” is 32-bit wide or 64-bit wide. If “normal” functions are undefined, I can grep them, but this is not possible here. Is there another good way to search the references? Some kind of “machine code grep”?
The module consists of some thousand lines of code. I can really not check every line manually.
First, you can do 64 bit division by using the
do_divmacro. (note the prototype isuint32_t do_div(uint64_t dividend, uint32_t divisor)and that “dividend” may be evaluated multiple times.Additionally, you should be able to either find usage of
long long int(oruint64_t) types in your code, or alternately, you can build your module with the-gflag and useobjdump -Sto get a source annotated disassembly.note: this applies to 2.6 kernels, I have not checked usage for anything lower