奇数编译的代码
odd compiled code
我已经用谷歌的nacl编译器编译了一些Qt代码,但ncval验证器没有找到它。众多例子中的一个例子:
src/corelib/animation/qabstractanimation.cpp:165
以下是相关代码:
#define Q_GLOBAL_STATIC(TYPE, NAME)
static TYPE *NAME()
{
static TYPE thisVariable;
static QGlobalStatic<TYPE > thisGlobalStatic(&thisVariable);
return thisGlobalStatic.pointer;
}
#ifndef QT_NO_THREAD
Q_GLOBAL_STATIC(QThreadStorage<QUnifiedTimer *>, unifiedTimer)
#endif
编译为:
00000480 <_ZL12unifiedTimerv>:
480: 55 push %ebp
481: 89 e5 mov %esp,%ebp
483: 57 push %edi
484: 56 push %esi
485: 53 push %ebx
486: 83 ec 2c sub $0x2c,%esp
489: c7 04 24 28 00 2e 10 movl $0x102e0028,(%esp)
490: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
494: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
49b: e8 fc ff ff ff call 49c <_ZL12unifiedTimerv+0x1c>
4a0: 84 c0 test %al,%al
4a2: 74 1c je 4c0 <_ZL12unifiedTimerv+0x40>
4a4: 0f b6 05 2c 00 2e 10 movzbl 0x102e002c,%eax
4ab: 83 f0 01 xor $0x1,%eax
4ae: 84 c0 test %al,%al
4b0: 74 0e je 4c0 <_ZL12unifiedTimerv+0x40>
4b2: b8 01 00 00 00 mov $0x1,%eax
4b7: eb 27 jmp 4e0 <_ZL12unifiedTimerv+0x60>
4b9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
4c0: b8 00 00 00 00 mov $0x0,%eax
4c5: eb 19 jmp 4e0 <_ZL12unifiedTimerv+0x60>
4c7: 90 nop
4c8: 90 nop
4c9: 90 nop
4ca: 90 nop
4cb: 90 nop
检查 49b 处的调用指令:这是验证者无法摸索的内容。到底是什么会诱使编译器发出一个调用自身中间的指令?有没有办法解决这个问题?我已经用-g -O0 -fno-inline编译了。编译器错误?
大概它实际上是对外部符号的调用,它将在链接时填充。实际上,将要调用的是externalSymbol-4,这有点奇怪 - 也许这就是使ncval验证器失去气味的原因。
这是一个动态库还是尚未链接到可执行文件的静态对象?
在动态库中,这可能是因为代码是作为位置依赖构建的,并链接到动态库中。尝试在上面尝试"objdump -d -r -R",如果你看到TEXTREL,就是这种情况。在 NaCl 动态链接故事中不支持 TEXTREL。(通过在编译代码期间使用 -fPIC 标志来解决)
对于静态对象,尝试在将其链接到静态可执行文件后进行验证。
相关文章:
- 如何修复sfml c++代码编译错误
- 尝试用java代码编译和运行c++代码
- 此代码编译良好,但文件未创建?请指出错误
- 为什么我的 BaseClass:Method 代码编译(带有单冒号)?
- 代码编译没有任何输出,入门程序
- 通过Python Distutils(用于Python C扩展)使用可重定位的设备代码编译CUDA代码
- 代码编译但不起作用!cmd窗口只是理想和理想,但什么也没发生
- 无法使用 g++ 使用C++代码编译 C 库
- 如何在Ubuntu中使用Visual Studio代码编译C++代码
- 推力+提升代码编译错误
- C++代码编译,但在 Zorin OS 上运行时显示错误
- 如何在使用模板时将 CPP 代码编译到库文件中
- 是否可以将Visual Studio 2017将C 代码编译到EXE以外的文件类型中
- 使用 Visual Studio for C++ 代码编译错误
- 使用 Android Studio 使用本机代码编译 apk 时,如何在链接处删除 libgnustl_static.
- 使用 Emscripten 将 OpenCV 代码编译C++ Javascript
- 将C 代码编译到独立应用程序.App
- 为什么此代码编译 (C++11) 而没有类型不匹配错误
- 重用编译器前端的结果,以加快多个配置/平台的C++代码编译
- 如何将C++11代码编译为网络汇编