相关疑难解决方法(0)

Arm 编译器 5 不完全尊重 易失性限定符

考虑以下代码:

volatile int status;

status = process_package_header(&pack_header, PACK_INFO_CONST);

if ((((status) == (SUCCESS_CONST)) ? ((random_delay() && ((SUCCESS_CONST) == (status))) ? 0 : side_channel_sttack_detected()) : 1))
{
    ...
}
Run Code Online (Sandbox Code Playgroud)

它生成此机器代码(使用工具链的objdump生成):

  60:   f7ff fffe       bl      0 <process_package_header>
  64:   9000            str     r0, [sp, #0]     /* <- storing to memory as status is volatile */
  66:   42a0            cmp     r0, r4           /* <- where is the load before compare? status is volatile, it could have change between the last store instruction (above line) and …
Run Code Online (Sandbox Code Playgroud)

c arm volatile armcc

5
推荐指数
1
解决办法
591
查看次数

标签 统计

arm ×1

armcc ×1

c ×1

volatile ×1