You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
SHT_NOTE sections (e.g. .note.gnu.build-id) can sometimes be aliased by a PT_NOTE segment. When this is the case, patchelf might move the SHT_NOTE section without also updating the PT_NOTE segment. The PT_NOTE segment ends up pointing to the middle of random stuff that might have been overwritten.
This is as far as I know the root cause of NixOS/nixpkgs#91145 breaking Mesa in NixOS with patchelf 0.11.
Steps To Reproduce
$ echo 'int foo(int x) { return x; }' > test.c
$ gcc -s -shared -Wl,-build-id -o test.so test.c
$ readelf -n test.so
Displaying notes found in: .note.gnu.build-id
Owner Data size Description
GNU 0x00000014 NT_GNU_BUILD_ID (unique build ID bitstring)
Build ID: 767c996573519ca3392910e472102d68d87342e7
$ patchelf --set-rpath $(perl -e 'print "A"x1000') test.so
$ readelf -n test.so
Displaying notes found in: .note.gnu.build-id
Owner Data size Description
readelf: Warning: note with invalid namesz and/or descsz found at offset 0x0
readelf: Warning: type: 0x3, namesize: 0x00000004, descsize: 0x00000014, alignment: 8
Expected behavior
Not completely sure yet. PT_NOTE should be updated, but that means we might need to ensure we keep multiple note sections adjacent if the PT_NOTE contains multiple SHT_NOTE sections.
patchelf --version output
master
The text was updated successfully, but these errors were encountered:
I implemented a fix in #218. I tested it with Mesa and confirmed that now Mesa is happily finding its build-id and not segfaulting anymore. readelf is also happy, though that was actually a separate problem from the section/segment mismatch! (alignment issue, see PR)
Describe the bug
SHT_NOTE
sections (e.g..note.gnu.build-id
) can sometimes be aliased by aPT_NOTE
segment. When this is the case, patchelf might move theSHT_NOTE
section without also updating thePT_NOTE
segment. ThePT_NOTE
segment ends up pointing to the middle of random stuff that might have been overwritten.This is as far as I know the root cause of NixOS/nixpkgs#91145 breaking Mesa in NixOS with patchelf 0.11.
Steps To Reproduce
Expected behavior
Not completely sure yet.
PT_NOTE
should be updated, but that means we might need to ensure we keep multiple note sections adjacent if thePT_NOTE
contains multipleSHT_NOTE
sections.patchelf --version
outputmaster
The text was updated successfully, but these errors were encountered: