Remove a program header

Fangrui Song i@maskray.me
Sat Apr 24 04:22:54 GMT 2021


On 2021-04-23, Peng Yu via Binutils wrote:
>Hi,
>
>It seems that there is not a readily available command to delete a
>program header, other than writing a C program to adjust the program
>headers following the one that is to be deleted.
>
>https://stackoverflow.com/questions/5877492/how-do-i-delete-a-program-header-from-an-elf-binary
>
>I also checked objcopy. It seems that it can only delete sections but
>not program headers. Is it so?
>
>Is there an easy-to-use command to delete a program header? Thanks.

Most objcopy features are for ET_REL. There is very little a binary
manimulation tool can do with ET_EXEC/ET_DYN without semantic information.

In ET_EXEC/ET_DYN, the static relocations infromation are lost (unless
--emit-relocs), so deleting some bytes or adding some bytes which affect
address space cannot generally work.

There are reverse engineering/pwning tools which can alter program
headers, but they cannot be 100% reliable.


More information about the Binutils mailing list