patchelf icon indicating copy to clipboard operation
patchelf copied to clipboard

Allow forcing a write-out of the ELF binary

Open rhaberkorn opened this issue 9 months ago • 0 comments

Is your feature request related to a problem? Please describe.

I stumbled across FreeBSD binaries - well rather Linux binaries run under Linuxulator - that cause the infamous "Program headers not in the first page" error. Turns out such ELF headers are still not supported as of FreeBSD 14.2. I found #153 where the issue was discussed. Indeed, recent patchelf versions write the ELF header at the beginning of the file, thus fixing the issue on FreeBSD.

Unfortunately, you might come across an existing ELF binary, that you would like to fix up without changing any of the settings that patchelf allows you to change.

Describe the solution you'd like

There should be an option to force the write out of a binary even when not changing any of the parameters. E.g. --force.

Describe alternatives you've considered

I found the following workaround:

patchelf --set-interpreter `patchelf --print-interpreter elf-binary` elf-binary

Additional context

I was testing with patchelf 0.14.3 on FreeBSD 14.2-RELEASE.

rhaberkorn avatar Feb 25 '25 11:02 rhaberkorn