So we have seen about e.l.f.
Headers and section headers, and the sections and section headers is used by linker right.
Uh section variable provides a information with a linker.
How to merge the sections and symbol resolution and all but using SGP have removed the section header
table.
But still we are able to execute the code.
So section header table does not.
Section headers are not used during execution.
It is only used during linking.
So to execute a piece of machine code, it has to be loaded into the memory and the information regarding
what all in uh code has to be loaded into memory is provided by program header.
So program header uh, also known as program segment header.
It provides information about how the segments of an executable file should be loaded into memory during
the program's execution.
Uh, it stores information about segments will see what the segments the section header table stores
information about sections.
Program header table stores information about segments.
It describes the location in the size of the segments.
It contains information needed by the OS to load the segment into process memory, and this is located
after the Elf header section header is located at the bottom of the Elf file, whereas program header
table is located after the Elf header, and one header exists for each segment, so it is similar to
the section header table, where section header exists for each segment.
Here, segment header exists or program header exists for each segment, and size of program header
is fixed.
So this is also same for section header.
So section header is also fixed.
And program segment header is also fixed so segments.
It breaks the whole Elf binary into suitable chunks to prepare the executable to be loaded into the
memory, and each segment is mapped, can be mapped to multiple sections, or sometimes there will be
no sections which are mapped to a segment, and not all sections will be loaded into the memory.
An Elf file consists of segments which is used to create a process or memory.
Image sections are used during the linking stage.
Segments are used during the runtime execution.
So really Lf command have an option to view the segments.
Hyphen l.
Hyphen h is for header.
Hyphen S is for sections, and small L is for the segments.
So let's go and see a simple code.
Let me see whether I have.
I'll go back to the same small code which we have.
This is a small code which we have, and I will generate this one.
File user space.
I'll delete this thing and I'll say.
No undefined reference to mean.
I need to remove the object file.
This is a very simple code.
I want to list all the segments I know.
I can list the headers using user space f and H.
I can list the section using capital S to list the segments.
I can use L command, so L command will give me the program header table or segment header table.
I can again use capital W here and it will print me in the right format.
So again you have a header a program header.
And you have different program headers and mapping between sections to segment is also provided.
So this program header has no mapping to zero sections.
This particular program header has mapping to one section which is interpreter section.
This has mapping to this many sections and this has mapping to this many sections of the file.
So mapping between sections and segments is also provided in the uh allowed hyphen L command.
And I have an Air Command prints all the information about the sections and segments, so I can use
that one for prints.
Uh, same section information for print.
So it will first print the letters.
It will print section headers.
It will print uh program headers and section to segment mapping and dynamic information and symbol table
information.
So Rudolph Hyphen is used to print all the information about the Elf file.
It is also printing some sections like note section where the information about the new version is used.
What Genie version glyphs you.
And the Buildid hash regarding the build the Linux API, which all this information is also printed
using read FNA.
So this is what each segment is mapped to multiple sections.
Now if you see here each segment is mapped to multiple sections.
If you see this particular segment second segment is mapped to multiple sections.
Not all sections will be mapped to a segment.
Here you can see some sections are not at all mapped to any particular segment okay.
So 11th is not having any sections at all.
And some segments will be empty also.
And not all sections will be get loaded into memory.