Size() vs ls -la vs du -h which one is correct size?

后端 未结 2 536
轻奢々
轻奢々 2020-12-03 22:27

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   8         


        
2条回答
  •  一个人的身影
    2020-12-03 23:18

    They are all correct, they just show different sizes.

    • 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.)

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

提交回复
热议问题