this post was submitted on 07 May 2025
5 points (100.0% liked)

Nix / NixOS

2216 readers
2 users here now

Main links

Videos

founded 2 years ago
MODERATORS
 

I'm trying to write a Nix package for a closed-source, precompiled binary with an unusual twist. The binary is statically-linked, but it contains an embedded binary that is dynamically-linked. Is there some way I can use patchelf or another tool to path the interpreter path in the embedded binary?

The embedded binary does not have any runtime library dependencies, but it does need an interpreter which it expects at the hard-coded path /lib64/ld-linux-x86-64.so.2. It is embedded using the golang "embed" library.

I have a workaround that wraps the binary using buildFHSEnv. That works, but the resulting closure is about 300 MB bigger than it needs to be.

you are viewing a single comment's thread
view the rest of the comments
[–] refalo@programming.dev 1 points 1 day ago

You could just change the path in the binary to a string that's smaller than what's in there now (or the same length), and pad any unused bytes with \0, then symlink that path to your real binary.