c++ - 获取二进制文件的数据和代码区域的大小

标签 c++ c unix

我有一个二进制可执行文件“foo”。在unix中使用C程序,是否可以检索文件foo的代码和数据区域的大小?

最佳答案

您可以使用size为此的命令。

男人尺寸

The GNU size utility lists the section sizes and the total size for each of the object or archive files objfile in its argument list. By default, one line of output is generated for each object file or each module in an archive.

示例:

$ size a.out
   text    data     bss     dec     hex filename
   1863     288       8    2159     86f a.out

关于c++ - 获取二进制文件的数据和代码区域的大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17070225/

相关文章:

c++ - 我可以将空指针传递给 memcmp 吗?

使用 C 将 UNIX 时间戳转换为秒/分钟/小时/月/年

c++ - 用 2x1 榻榻米垫填充 HxW 房间有多少种方法?

c++ - 为什么指向 NULL 字符的指针未转换为 false

c - 对整数的奇数位求和的递归函数

c - 是否可以让 bash 检测 C 中的编译错误?

c - 这个变量的值在我的 C 代码中如何变化?

python - 是否有一个内置的 python 模拟 unix 'wc' 用于嗅探文件?

bash - 以特定格式格式化日志

c++ - 查找两个 vector 之间的最大元素