Live data from Hacker News

PatchELF: Simple utility for modifying existing ELF executables and libraries

github.com

1–10 of 42 posts

Re: PatchELF: Simple utility for modifying existing ELF executables and libraries

#3

Apart from adapting proprietary or hard-to-compile software to non-FHS distros like NixOS or Guix, what are the usecases of patchelf?

Some of the things it does are extremely handy for simple privilege escalation attacks.

Re: PatchELF: Simple utility for modifying existing ELF executables and libraries

#4

Apart from adapting proprietary or hard-to-compile software to non-FHS distros like NixOS or Guix, what are the usecases of patchelf?

Being able to add or update the rpath on apps and shared objects is pretty handy, particularly when the target would be annoying or problematic to rebuild.

Re: PatchELF: Simple utility for modifying existing ELF executables and libraries

#5

Apart from adapting proprietary or hard-to-compile software to non-FHS distros like NixOS or Guix, what are the usecases of patchelf?

I've used it to edit a binary's rpath as part of relocating binaries that really want to be installed at a certain path.

You can do this yourself with e.g. hexedit if your new path is shorter but if it's longer you need something smarter, like patchelf.

Re: PatchELF: Simple utility for modifying existing ELF executables and libraries

#6

Apart from adapting proprietary or hard-to-compile software to non-FHS distros like NixOS or Guix, what are the usecases of patchelf?

Being able to add or update the rpath on apps and shared objects is pretty handy, particularly when the target would be annoying or problematic to rebuild.

To add, there's chrpath(1), but that can't grow the field in the ELF file, so you can only change the rpath to something shorter than it is now, and usually it's empty.

Re: PatchELF: Simple utility for modifying existing ELF executables and libraries

#7

Apart from adapting proprietary or hard-to-compile software to non-FHS distros like NixOS or Guix, what are the usecases of patchelf?

Lots of Python packages containing native code are optionally distributed with pre-compiled libraries that have been modified with patchelf. I believe both auditwheel (https://pypi.org/project/auditwheel/) and conda-build do this.

Re: PatchELF: Simple utility for modifying existing ELF executables and libraries

#8

Apart from adapting proprietary or hard-to-compile software to non-FHS distros like NixOS or Guix, what are the usecases of patchelf?

Sounds like something that would make binary patching easier. Lack of simple binary patching is one of the key bits missing that would make switching to static binaries more viable. Currently one of the big upsides to dynamic libraries is the bandwidth they save in distribution where binary patches would go a long way to addressing this.

Re: PatchELF: Simple utility for modifying existing ELF executables and libraries

#10
https://nixos.org/guides/nix-pills/automatic-runtime-depende...

Part of the excellent "nix pills" guide on why things are the way they are in Nix, and why this tool was created.

The whole series is a pretty easy evening read if you have experience in functional languages (like haskell), and really helps you appreciate what nix is doing.

One of my main reservations about Nix and introducing it at work is basically requiring that other developers wrap their minds around functional concepts like partial application.

This might just be an imagined problem, but not one I want to spend cycles explaining to the higher-ups

Post reply on HN