So here is a very simple example.
Uh, for a C program which just returns three and it has only one instruction.
Right.
Return three.
Now if I compile this using gcc it will give me an elf file.
Right.
And the file is in.
We have a file which is a 64 bit.
I have only one instruction which is just returning three.
And let's look into the size of this zero space.
It is having almost 17,000 instructions.
17 K of instructions.
Right.
And why is it like it has so much of instructions?
I can see I'll just say give me only relocatable file.
So it will give me a relocatable file, which is this one.
And it is.
Oh let's check the.
Size.
This is 1.4 K.
So relocatable file is having 1.4 k but executable file when once the linker takes this relocatable
file, the object file and converts it to an executable to increased to almost 17 k a huge amount of
size.
So there are 17,000 instructions added.
Is it like that?
Let's see.
Verify objdump hyphen d user space dot o.
So it has so many instructions apart from returning five or returning uh three here which is returning
three where it is keeping the X register.
It is adding so many instructions.
Uh, and this is the form.
This is because of Elf file format.
Just returning number three is not, uh, present in the object code.
It has so much of, uh, machine instructions.
If you see into the final executable, it has so many instructions, it is performing a lot of instructions.
So we will understand.
What are these, uh, instructions?
What is the structure of this step by step.
So you can also easily understand just seeing this will not be will not be easily understanding.
So we'll start with the that's the reason we have uh divided into the parts elf header section, header
segments program header and the final object code actual machine instructions.
So we'll start with the elf header and then we'll go next section header and the program header.