Size()vs ls -la vs du -h哪个是正确的大小? [英] Size() vs ls -la vs du -h which one is correct size?

查看:136
本文介绍了Size()vs ls -la vs du -h哪个是正确的大小?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编译一个自定义内核,所以我想测试图像文件的大小. 这些是结果:

I was compiling a custom kernel, and I wanted to test the size of the image file. These are the results:

ls -la | grep vmlinux
-rwxr-xr-x   1 root   root   8167158 May 21 12:14 vmlinux

du -h vmlinux
3.8M    vmlinux

size vmlinux
   text    data     bss     dec     hex filename
2221248  676148  544768 3442164  3485f4 vmlinux

由于它们均显示不同的尺寸,因此哪一个最接近实际图像尺寸? 他们为什么不同?

Since all of them show different sizes, which one is closest to the actual image size? Why are they different?

推荐答案

它们都是正确的,只是显示不同的大小.

They are all correct, they just show different sizes.

  • ls显示文件的大小(当您打开并阅读文件时,这就是您将获得的字节数)
  • du显示的实际磁盘使用情况可能会由于漏洞而小于文件大小
  • size显示对象/可执行文件的运行时映像的大小,该映像与文件的大小不直接相关(bss不管文件多大都不会使用字节,文件可能包含调试信息,即不属于运行时映像等)
  • ls shows size of the file (when you open and read it, that's how many bytes you will get)
  • du shows actual disk usage which can be smaller than the file size due to holes
  • size shows the size of the runtime image of an object/executable which is not directly related to the size of the file (bss uses no bytes in the file no matter how large, the file may contain debugging information that is not part of the runtime image, etc.)

如果您想知道可执行文件将占用多少RAM/ROM(不包括动态内存分配),size会为您提供所需的信息.

If you want to know how much RAM/ROM an executable will take excluding dynamic memory allocation, size gives you the information you need.

这篇关于Size()vs ls -la vs du -h哪个是正确的大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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