在-ffunction节&安培查询; GCC的-fdata截面的选择 [英] Query on -ffunction-section & -fdata-sections options of gcc

查看:226
本文介绍了在-ffunction节&安培查询; GCC的-fdata截面的选择的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在GCC页以下提到的功能部分和数据部分选项:


  -ffunction截面
-fdata截面


  
  

将每个函数或数据项存放到输出文件中其自己的部分,如果target支持任意部分。的功能或数据项的名称的名称在输出文件确定部分的名称。
  使用系统上的这些选项,其中链接器可以执行优化,以提高在指令空间局部性。使用ELF对象格式大多数系统和运行Solaris 2 SPARC处理器有这种优化接头。 AIX可能在未来这些优化。


  
  

只有当有这样做的好处显著使用这些选项。 当指定这些选项时,汇编器和链接器将生成较大的目标和可执行文件,并会慢一些。:您将无法在所有系统上使用gprof的,如果你指定此选项,如果你指定此选项和-g你可能有调试问题。


我是IM pression这些选项会减少可执行文件大小的帮助下。为什么这个页面说,这将创造更大的可执行文件?我缺少的东西吗?


解决方案

在使用这些编译器选项,你可以添加链接选项 - GC-部分(可能是错误的名称),将删除所有未使用code。

The below mentioned in the GCC Page for the function sections and data sections options:

-ffunction-sections
-fdata-sections

Place each function or data item into its own section in the output file if the target supports arbitrary sections. The name of the function or the name of the data item determines the section's name in the output file. Use these options on systems where the linker can perform optimizations to improve locality of reference in the instruction space. Most systems using the ELF object format and SPARC processors running Solaris 2 have linkers with such optimizations. AIX may have these optimizations in the future.

Only use these options when there are significant benefits from doing so. When you specify these options, the assembler and linker will create larger object and executable files and will also be slower. You will not be able to use gprof on all systems if you specify this option and you may have problems with debugging if you specify both this option and -g.

I was under the impression that these options will help in reducing the executable file size. Why does this page say that it will create larger executable files? Am I missing something?

解决方案

When using those compiler options, you can add the linker option --gc-sections (could be wrong name) that will remove all unused code.

这篇关于在-ffunction节&安培查询; GCC的-fdata截面的选择的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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