为什么普通C编译器在输出中包括源文件名? [英] Why do common C compilers include the source filename in the output?

查看:122
本文介绍了为什么普通C编译器在输出中包括源文件名?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从这个最近的回答了解到 gcc clang 将二进制文件中的源文件名包含为元数据,即使未启用调试。

I have learnt from this recent answer that gcc and clang include the source filename somewhere in the binary as metadata, even when debugging is not enabled.

了解为什么这应该是一个好主意。除了微小的隐私风险,这也发生在一个优化的结果二进制( -Os )的大小,这看起来效率低下。

I can't really understand why this should be a good idea. Besides the tiny privacy risks, this happens also when one optimizes for the size of the resulting binary (-Os), which looks inefficient.

为什么编译器包含这些信息?

推荐答案

GCC包含文件名的原因主要是为了调试目的,因为它允许程序员从 ELF spec p1-17 ,并在某些Oracle文档链接

使用 STT_FILE 部分的示例由

An example of using the STT_FILE section is given by this SO question.

这篇关于为什么普通C编译器在输出中包括源文件名?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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