NixOS / patchelf

A small utility to modify the dynamic linker and RPATH of ELF executables
GNU General Public License v3.0
3.48k stars 483 forks source link

patchelf: cannot normalize PT_NOTE segment: non-contiguous SHT_NOTE sections #546

Open akgrant43 opened 6 months ago

akgrant43 commented 6 months ago

Describe the bug

Attempting to patchelf a rust executable to run on NixOS and hitting the error from the subject:

$ patchelf --set-interpreter /nix/store/8mc30d49ghc8m5z96yz39srlhg5s9sjj-glibc-2.38-44/lib/ld-linux-x86-64.so.2 ./GlamorousToolkit-cli
patchelf: cannot normalize PT_NOTE segment: non-contiguous SHT_NOTE sections

$ patchelf --version
patchelf 0.18.0

A few notes:

I've seen previous issues opened about this (#217, #255, #400) however they don't appear to be the same.

Steps To Reproduce

Download and unzip GlamorousToolkit-cli:

wget https://github.com/feenkcom/gtoolkit-vm/releases/download/v1.0.14/GlamorousToolkit-x86_64-unknown-linux-gnu.zip
unzip GlamorousToolkit-x86_64-unknown-linux-gnu.zip
cd bin

Find an interpreter (this is just for demo purposes, not production code):

GT_INTERPRETER=$(find /nix/store -name ld-linux-x86-64.so.2 | grep 2.38 | head -n 1)
echo $GT_INTERPRETER

attempt to patch the exe:

patchelf --set-interpreter $GT_INTERPRETER GlamorousToolkit-cli

The same issue occurs when attempting to to set the rpath.

Expected behavior

The executable is updated with the specified interpeter.

patchelf --version output

$ patchelf --version
patchelf 0.15.0

and

$ patchelf --version
patchelf 0.18.0

Additional context

None.

nixos-discourse commented 6 months ago

This issue has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/patchelf-cannot-normalize-pt-note-segment-non-contiguous-sht-note-sections/40561/2

akgrant43 commented 1 week ago

patchelf 0.11.20200609.d6b2a72 doesn't have this problem (tag 0.11 in the repository), 0.12 does.