In the previous video we have looked about strip command.
We also have one more utility known as a strip section strip.
So this is a small utility which removes as much as possible from a file without affecting the files
memory image.
So we know all Elf executables has an Elf header, program header table and section header table.
But to run the executable file we only need the program header table and the Elf header.
We do not need the section header table okay, so only this is needed.
This is only needed during the link stage program.
Table is used during the load stage or the execution of the program.
So a strip will remove.
It will keep the Elf header, the program header table and its content and it will leave everything
else okay, only it will keep the header program, header table and the contents of the program header
table.
But if it is very important that most programs which works with Elf file are dependent on the section
header table, if I don't have section header table, they will not work like GDB and objdump will have
limited functionality.
So let's see how I can use this one I will.
Okay.
Um, saying this, I'm cloning this.
This is not available as a sudo apt get command.
So you need to clone this from GitHub and we need to compile this one.
So I have this make.
So now uh I will copy the bin LHS here.
So I have LHS command which is like I have copied.
So it has uh let's see what all the sections we have now LHS has like 29 sections.
Right.
Now let's see what all commands you need to type.
Now it has this many sections 20 and 30 sections.
Now I will run a strip on this.
Let's.
And now let's see.
I don't have any sections in this.
If I do a file command on this ls it still saying this information?
But it's saying no section header.
So this information it is getting from the elf uh, headers and but this because it is not having the
sections, it is saying no section in the file.
Now if I run this command I get the same functionality.
What I am getting the before it.
So it is working.
But.
I don't have any sections now, so what I wanted to convey in this example is section headers are used
only during the linking stage during the program execution.
Section headers are not used.
Only the program header table and its corresponding contents contents are used during execution.
So we'll also verify one more example.
So this is a simple code again.
So I have this user space uh here.
So I'll use this.
So currently the size of user space uh is like 15 KB.
Now it has different sections and 28 sections.
Now when I run this here using I am going to remove all the sections from this user space.
Okay I need to pass dot slash.
Uh.
Now, if you see there are no sections in the file, and the size which was previously is reduced to
KB of size has been reduced related to the section header table and the program works whatever is expected.
Behavior is coming.
I can see whether NM works because NM uses a section header table.
It uses one of the section which is string table, and all NM is not working because it is not seeing
it.
Corresponding sections and Objdump.
Let's see Objdump works Objdump hyphen d Objdump also is not working, so Rudolph hyphen h will work
because it is header.
But Rudolph hyphen S is not working.
So objdump.
Let's see GDB will work.
It is not finding any debugging symbols or debugging symbols, but I have not compiled using debugging
symbols, right?
Uh, so gdb should work.
It's just running the code.
But if I remove if I compile using gcc, uh, it will remove all those debugging symbols, right?
The debug line, debug string and step removes everything.
It removes all the sections.
It only keeps the program header table and it will only keep the elf header.
And those are only needed during the execution.
So we know section headers are used during linking and program headers are used during execution.