Before going to the minimal Elf file, I want to test one more thing.
What happens if I compile this code into a static executable?
Till now we are seeing dynamic executables, right?
So if I say make user space uh.
This is a dynamic executable okay.
Now I will have compile this into static user space and also static.
So this will not use dynamic libraries and read elf hyphen h static user space will give.
It is a type of executable.
Here it is saying dynamic because it is using the dynamic libraries.
Now if we check the headers.
Segments in.
This one is having two L segments and is having an interpreter as well, which is used to load a dependency
libraries.
But in check this one.
In the static thing it is having less number of segments, only ten segments, ten program headers or
ten segments.
Here 13 it is having this is having interpreter.
But this is not having interpreter.
And this is not even having the program header type okay.
This is reducing the number of segments are reduced in the static.
And if you compare the maps file also when I run this one.
And look at the PID first.
So 44869 cat proc four four and six nine maps file is.
This is the dynamic library.
It has lot of uh entries in the virtual outer space.
It has C library included.
Has loader included in it.
Now if I look into this from the static user space 45001.
Thermophiles are less number of entries in the virtual address space of the processor less.
It has only few entries.
Does not have C library.
Does not have loader, but it has the same heap stack all those.
But this entry is related to the loader in the C library are gone because it does not have an interpreter
section.
So this is a difference we can see from the segment view of the Elf file.
But if you compare the.
Uh, if you compare the sections, uh, if of between this one and.
Static one.
There is not much difference in 31 extra section is added uh in the static binary when compared to the
dynamic dynamic thing.
See something less tedious and static.
It's an extra section is added in the static space, uh, executable and computer dynamic executable.
And the more major difference is the size of it.
Static will take so much of size C uh, it takes 852 KB and this is only taking 17 KB.