In this video we'll be looking into size command, size, command.
It lists section sizes and total size.
It only lists information about the text, data and BSS.
Not all the sizes, all section sizes, only the few section sizes like text, data and BSS.
And the size command works only on object and executable files.
If you're trying to run on a simple Ascii file, it will throw an error.
So I'm creating a file simple Ascii file, and it is simple Ascii text and size.
And it is saying file format not recognized.
So size will only work on object in executable files.
So I can say check how much is the size of text section in the LHS.
There's this many bytes and the data section has this many bytes.
And if you combine all this it will be this one.
Okay, this is nothing but addition of all this into this.
And then this is in binary decimal format and this is in hexadecimal format.
I can check in and see all how much is the text section, how much the data section and how much is
the, uh section.
All this information is present uh, in this section, which is printing the same thing here.
So if I just say f w s.
Okay, so this should give me the size of the text section is this particular section.
And it should also convert this here to this.
Okay.
Whatever is here will come here.
So it is using all the section face stress which is reading the section header table.
And it is uh printing the values.
It is reading section under table.
And the first command uses the section table and prints it.
So for example, this simple code we have where we have compiled the object file and uh executable.
Let's look into this.
So as a size of the user space.
Oh it says that I have texts of 113 bytes.
That section is taking 12 bytes.
So it will uh and this is coming here as zero.
Now when compared this with this thing, it says when the section comes into picture, uh, the linker
is taking this assembly object and creating the base, also creating a base section.
It is giving like eight bytes.
And data section is increased because C library global variables also come into picture.
Text section is also increased.
Now if I remove this, comment this one and verify whether any change happens.
So I'll say this is a C user space dot c and I'll compile an executable.
And let's verify size object.
So no change in the size or anything and no change in the data in these as well.
So uh, if even if I have commented this because it's not used, maybe uh, this is just optimized it,
but if you are using it you should see a change in the base value.