__udivdi3 undefined — 如何找到使用它的代码? [英] __udivdi3 undefined — how to find the code that uses it?

查看:12
本文介绍了__udivdi3 undefined — 如何找到使用它的代码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 32 位 Linux 内核上编译内核模块会导致

Compiling a kernel module on 32-Bit Linux kernel results in

"__udivdi3" [mymodule.ko] undefined!
"__umoddi3" [mymodule.ko] undefined!

在 64 位系统上一切正常.据我所知,这是因为 32 位 Linux 内核不支持 64 位整数除法和取模.

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.

如何找到发出 64 位操作的代码.它们很难手动找到,因为我无法轻松检查/"是 32 位宽还是 64 位宽.如果未定义正常"函数,我可以 grep 它们,但这在这里是不可能的.还有另一种搜索参考文献的好方法吗?某种机器代码grep"?

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.

推荐答案

首先,您可以使用 do_div 宏进行 64 位除法.(注意原型是 uint32_t do_div(uint64_tdivide, uint32_t divisor) 并且dividend"可以被评估多次.

First, you can do 64 bit division by using the do_div macro. (note the prototype is uint32_t do_div(uint64_t dividend, uint32_t divisor) and that "dividend" may be evaluated multiple times.

{
    unsigned long long int x = 6;
    unsigned long int y = 4;
    unsigned long int rem;

    rem = do_div(x, y);
    /* x now contains the result of x/y */
}

此外,您应该能够在代码中找到 long long int(或 uint64_t)类型的用法,或者,您可以使用-g 标记并使用 objdump -S 获取带注释的源代码反汇编.

Additionally, you should be able to either find usage of long long int (or uint64_t) types in your code, or alternately, you can build your module with the -g flag and use objdump -S to get a source annotated disassembly.

注意:这适用于 2.6 内核,我没有检查任何更低的使用情况

note: this applies to 2.6 kernels, I have not checked usage for anything lower

这篇关于__udivdi3 undefined — 如何找到使用它的代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆