You're right, you definitely can strip away the section headers. Notice that there's always a dynamic segment? If there wasn't, stripping away the section headers would make it very difficult to locate this very important piece of an ELF binary.
I had to make sure that I always inserted a page size multiple of bytes into the executable which can add up to a page of unused padding in addition to the thunk and chunk.
Good point! I was aware that there are certain circumstances in which argv[0] might not contain the path to the executable but I didn't bother to look for an alternative. When I get a chance, I'll incorporate your suggestion. Thanks.
Yes, I've implemented this technique before at my job. Relocating assembly instructions especially those that contain branching logic can be tricky as the offsets have to be recomputed or a new instruction needs to be used instead. More often that not, you may not have enough space for that new instruction.
I wrote the project entirely for fun, as a learning experience and because of that I have not extensively tested it. At the moment only ELF files of type ET_EXEC can be injected.
I was careful to only inject the thunk (the code that loads the actual relocatable code chunk the the user injects) into the available padding at the end of the text segment, injecting anything larger runs the risk of "sliding" the next segment (usually the data segment) over thereby breaking references to static data from code.