首页 > 解决方案 > 如何让 GCC 不生成 endbr64?

问题描述

我的 gcc 版本是 9.3.0

gcc (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0
Copyright (C) 2019 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE

根据 gcc 9.3 手册

-mmanual-endbr
仅通过 cf_check 函数
属性在函数入口处插入 ENDBR 指令。当与选项“-fcf-protection=branch”
一起使用以控制函数入口处的 ENDBR 插入时,这很有用。

据我了解,如果我使用以下命令编译一些东西:

gcc -fcf-protection=branch -mmanual-endbr sth.c -o sth

main 函数没有 cf_check 属性,所以 main 入口处应该没有 endbr64。

但事实证明,在入口处仍然有 endbr64。

那么,如何让GCC不生成endbr64呢?

谢谢。

标签: cgcc

解决方案


推荐阅读