In this video we'll be looking into the program headers.
How the structures are present.
So program header in the Elf specifies which section of the Elf file goes to a particular memory location
or segments section is and segments are can be used interchangeably.
So segment can be multiple section.
There is a mapping of uh segment to section in the Elf hyphen L command.
So the variables which are related to program headers in the Elf header is again similar to the section
header.
So you have start of the section header right.
Similarly you have start of the program header.
And we can see program header starts after the elf header.
The size of the yellow header is 64 bytes, and the offset of the program header is also 64 bytes.
So after the Elf header, the program header starts.
And then we have number of program header entries.
How many program header entries you have 13.
So and what is the size of this program header.
So we have seen almost all in the header till now.
So we have seen the section headers with the start of the location of the section header.
And we have seen the program header start of the program header, how many parameters we have and what
is the size of this uh program header.
And then they have this particular structure, this I have copied from the elf dot h.
You have a type like you have section header type.
You have section header flags.
You have program header type parameter flags offset virtual address physical address.
Now we have additionally physical address.
What is the size of the segment in the memory.
Uh file file size.
Segment size in the memory.
So type like we have type program bits and all know bits right in the.
Sections, uh, like program bits, no bits and all, symbol table and all.
We have same thing in, uh, the program headers.
We have something like p header.
P header means it is indicates the beginning of the program.
Header part load program header type load.
It means it contains data that has to be loaded into the memory.
So the most important program header is this load and interpreter.
So these are the things which are getting loaded into the memory.
Then we have PD interpreter, which indicates a program path which will be acting as an interpreter
for the Elf file.
And we know this is the interpreter we have seen in the sections.
Right.
Interpreter mapping is.
So this segment is only mapping to one section which is interpreter section.
And then we have node section.
This contains informational text that should not be loaded anywhere.
So we do not have any specific type here.
So so we have seen the type.
The most important type are load and interpreter and dynamic.
We have dynamic is mapping.
So didn't seem we can see whether yeah we have didn't seem and dynasty are also which are getting loaded.
We have text section and all in a particular segment text section in it.
And and then we have data section, these sections all in a different uh segment.
And they have some permissions like flags whether it is read only or executable.
So only one particular segment is executable which is this 0123.
This is where your code is present.
So only the section or segment where the code is present uh, which is having text section and in it.
And finally here is where we are giving the flag as executable when it is read only because we don't
change the code.
But when it comes the data, that data in it is having the fifth sections RW read and write permissions.
So RW is for data and the stack is also having read and write permissions.
And so are means readable right?
Writable and executable.
So executable.
We are only giving to the section which is having the code which is the text section.
And then offset.
Offset specifies information about where this data is in the file.
So we have offset.
So header is present at the location 64.
And then you have interpreter which is present in the location this particular location.
And we can verify that using hex and see what is present in this location.
And then you have file size.
What is the size of this file in the memory.
So this is like one c.
So if you count this it should be one c.
And what is the memory size when this is in the memory.
Uh in that this is the size in the file.
And this is the size in the memory the ram.
What will be the size if you will be seeing some of them will have uh, uh, file size less than file
size is less and memory size is more.
And this is like 012345.
And this is where your BS comes.
So whenever your BS comes into picture you'll be seeing uh file size is less uh and memory size is more.
Here it is.
It.
This is our.