小编use*_*210的帖子

手臂皮质a9交叉编译奇怪的浮点行为

我试图将一个更大的应用程序从x86移植到arm cortex a9,但是当交叉编译应用程序时,我得到了像modf这样的浮点函数的奇怪分段错误,其他libc ++函数似乎只是处理浮动错误,但不会崩溃(见下文).

所以我尝试了这个小测试程序,它也可以触发错误.测试程序的输出(见下文)应该证明我的问题.

#include <iostream>
int main(int argc, char *argv[])
{
    double x = 80;
    double y = 0;
    std::cout << x << "\t" << y << std::endl;
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

编译在arm cortex a9上:

@tegra$ g++ -Wall test.cpp -o test_nativ
@tegra$ ./test_nativ 
80      0
Run Code Online (Sandbox Code Playgroud)

交叉编译

@x86$ arm-cortex_a9-linux-gnueabi-g++ test.cpp  -o test_cc
@tegra$ ./test_cc
0       1.47895e-309
Run Code Online (Sandbox Code Playgroud)

使用'-static'链接器选项进行交叉编译.

@x86$ arm-cortex_a9-linux-gnueabi-g++ -static test.cpp  -o test_cc_static
@tegra$ ./test_cc_static 
80      0
Run Code Online (Sandbox Code Playgroud)

.

@x86$ arm-cortex_a9-linux-gnueabi-objdump -S test_cc
see: http://pastebin.com/3kqHHLgQ

@tegra$ objdump -S test_nativ
see: http://pastebin.com/zK35KL4X …
Run Code Online (Sandbox Code Playgroud)

c c++ floating-point arm cross-compiling

7
推荐指数
1
解决办法
2038
查看次数

标签 统计

arm ×1

c ×1

c++ ×1

cross-compiling ×1

floating-point ×1