加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

c – 替换GCC中的“fvtable-gc”

发布时间:2020-12-16 07:05:03 所属栏目:百科 来源:网络整理
导读:是否有替换GCCv4.7.1中的’fvtable-gc’选项(GCCv3.x支持)?我想在链接过程中删除未使用的虚函数. fvtable-gc Emit special relocations for vtables and virtual function references so that the linker can identify unused virtual functions and zero o
是否有替换GCCv4.7.1中的’fvtable-gc’选项(GCCv3.x支持)?我想在链接过程中删除未使用的虚函数.

fvtable-gc
Emit special relocations for vtables and virtual function references so that the linker can identify unused virtual functions and zero out vtable slots that refer to them. This is most useful with -ffunction-sections and -Wl,–gc-sections,in order to also discard the functions themselves.

解决方法

看起来这个功能太多了,所以它已经在几年前删除了.我认为没有相应的替代品.

虽然我还没有找到官方声明,但有几条评论说fvtable-gc至少在GCC 3.x系列中被打破,可能更早.例如(source: cris.h; claiming to be part of GCC):

… When bugs are removed from -fvtable-gc (-fforce-addr causes invalid .vtable_entry asm in tinfo.cc and nothing at all works in GCC 3.0-pre) …

多年以后的今天,编译器应该更加先进.也许GCC的整个程序优化器足够聪明,可以检测并消除未使用的虚函数,但我不确定.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读