In fact when we add a segment in a static (or more generally not relocatable) binary, LIEF moves the program headers at the end of the binary. The assumption of the libc is false.
I suggest you to move to the HEAD version of LIEF (v0.8.0 is coming soon)
Here is the workaround
Tried to make a simple packer using lief, but it turns out I was never able to make a working binary while using lief.ELF.add_segment() function.
Reproduction steps are easy, just follow https://lief.quarkslab.com/doc/tutorials/05_elf_infect_plt_got.html and at step
Injecting the hook
, lief failed to add the segment on debian unstable.On some other tests, binaries were successfully written but could not be executed. This seems to happen when adding a segment to a static binary.
Here is a sample program:
Then:
Then using the following lief script:
And doing that right after fails:
The text was updated successfully, but these errors were encountered: