endbr64指令实际上是做什么的? [英] what does endbr64 instruction actually do?

查看:4352
本文介绍了endbr64指令实际上是做什么的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直试图理解由GCC生成的汇编语言代码,并经常在包括_start()在内的许多函数启动时遇到此指令,但找不到任何说明其用途的指南

I've been trying to understand assembly language code generated by GCC and frequently encounter this instruction at start of many functions including _start(), but coudn't find any guide explaining it's purpose

31-0000000000001040 <_start>:
32:    1040:    f3 0f 1e fa             endbr64 
33-    1044:    31 ed                   xor    ebp,ebp

推荐答案

它代表"64位结束分支"-更准确地说,是64位终止间接分支

It stands for "End Branch 64 bit" -- or more precisely, Terminate Indirect Branch in 64 bit

英特尔拥有有关此说明的文档.

以下是操作:

IF EndbranchEnabled(CPL) & EFER.LMA = 1 & CS.L = 1
  IF CPL = 3
  THEN
    IA32_U_CET.TRACKER = IDLE
    IA32_U_CET.SUPPRESS = 0
  ELSE
    IA32_S_CET.TRACKER = IDLE
    IA32_S_CET.SUPPRESS = 0
  FI
FI;

否则,该指令被视为NOP.

CET功能用于确保您的间接分支实际进入有效位置.这样可以增加安全性.这是英特尔关于它的一段:

The CET feature is used to make sure that your indirect branches actually go to a valid location. This allows for additional safety. Here is the paragraph from Intel about it:

ENDBRANCH(有关详细信息,请参见第73节)是一条新指令,用于标记程序中间接调用和跳转的有效跳转目标地址.该指令操作码被选择为旧机器上的NOP,以便使用ENDBRANCH新指令编译的程序继续运行 在没有CET强制执行的旧计算机上.在支持CET的处理器上,ENDBRANCH仍然是NOP,并且主要由处理器管道用作标记指令以检测违反控制流的行为. CPU实现了一个状态机,该状态机跟踪间接的jmp和调用指令.当其中之一 看到指令,状态机从IDLE移到WAIT_FOR_ENDBRANCH状态.在WAIT_FOR_ENDBRANCH状态下,程序流中的下一条指令必须是ENDBRANCH.如果未看到ENDBRANCH,则处理器会导致控制保护异常(#CP),否则状态机将返回IDLE状态.

The ENDBRANCH (see Section 73 for details) is a new instruction that is used to mark valid jump target addresses of indirect calls and jumps in the program. This instruction opcode is selected to be one that is a NOP on legacy machines such that programs compiled with ENDBRANCH new instruction continue to function on old machines without the CET enforcement. On processors that support CET the ENDBRANCH is still a NOP and is primarily used as a marker instruction by the processor pipeline to detect control flow violations. The CPU implements a state machine that tracks indirect jmp and call instructions. When one of these instructions is seen, the state machine moves from IDLE to WAIT_FOR_ENDBRANCH state. In WAIT_FOR_ENDBRANCH state the next instruction in the program stream must be an ENDBRANCH. If an ENDBRANCH is not seen the processor causes a control protection exception (#CP), else the state machine moves back to IDLE state.

这篇关于endbr64指令实际上是做什么的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆