编译内核模块时"__floatsidf"未定义警告

Var*_*ári 5 c linux-kernel

我正在编写一个可加载的内核模块,当尝试编译它时,链接器失败并显示以下消息:

*** Warning: "__floatsidf" [/testing/Something.ko] undefined!
Run Code Online (Sandbox Code Playgroud)

我不使用浮点变量,所以不是这样.造成这种错误的原因是什么?

注意:我正在使用 Linux ubuntu kernel v. 3.5.0-23-generic

Car*_*rum 7

__floatsidf是一个运行时例程,用于将32位有符号整数转换为双精度浮点数.项目中的某个位置如下所示:

double foo = bar;
Run Code Online (Sandbox Code Playgroud)

或类似的东西,其中bar是32位整数.也可能是你正在调用一个libm函数(或任何其他函数,实际上),它需要一个double整数参数:

foo = pow(bar, baz);
Run Code Online (Sandbox Code Playgroud)

其中bar或者baz(或两者)是整数.

如果没有显示某些代码,我们无法提供更多帮助.

要缩小范围,请检查编译器生成的目标文件(在链接它们之前)并查看反汇编以获取对该符号的引用 - 这应该告诉您它正在发生什么功能.

这是我的意思的一个例子.首先 - 源代码:

#include <math.h>

int function(int x, int y)
{
    return pow(x, y);
}
Run Code Online (Sandbox Code Playgroud)

很简单,对吧?现在,我将为ARM编译并反汇编:

$ clang -arch arm -O2 -c -o example.o example.c
$ otool -tV example.o 
example.o:
(__TEXT,__text) section
_function:
00000000    e92d40f0    push    {r4, r5, r6, r7, lr}
00000004    e28d700c    add r7, sp, #12
00000008    e1a04001    mov r4, r1
0000000c    ebfffffb    bl  ___floatsidf
00000010    e1a05000    mov r5, r0
00000014    e1a00004    mov r0, r4
00000018    e1a06001    mov r6, r1
0000001c    ebfffff7    bl  ___floatsidf
00000020    e1a02000    mov r2, r0
00000024    e1a03001    mov r3, r1
00000028    e1a00005    mov r0, r5
0000002c    e1a01006    mov r1, r6
00000030    ebfffff2    bl  _pow
00000034    ebfffff1    bl  ___fixdfsi
00000038    e8bd40f0    pop {r4, r5, r6, r7, lr}
0000003c    e12fff1e    bx  lr
Run Code Online (Sandbox Code Playgroud)

看那个-两次调用__floatsidf一到__fixdfsi,匹配的两次转换x,并ydouble再返回的转换类型回int.