c++ - 奇怪的编译代码

标签 c++ qt assembly x86 google-nativeclient

我已经用谷歌的 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 验证器失去嗅觉的原因。

关于c++ - 奇怪的编译代码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10523065/

相关文章:

assembly - 如何在 x86(32 位)程序集中将无符号整数转换为 float ?

c++ - 这是允许的 : memcpy(dest, src, 0)

c++ - 在单个函数调用中发出 Qt HTTP 请求并接收响应

c++ - 编译错误 QT - 无法从类型进行转换

qt - 具有属性的 QML StackView 推送组件

assembly - 从设置 EIP=00000000 的指令中恢复

linux - 如何将此 linux 汇编代码更改为兼容的 UNIX 汇编代码?

c++ - 为什么我的代码在运行时会一直循环

c++ - 如何在cmake中正确使用include_directories?

c++ - p。上缺少成员初始化程序列表的示例。 184《使用C++进行编程的原理和实践》,第二版