Skip to content

Commit 08c172a

Browse files
lkollarrdb
authored andcommitted
Apply patch in patchelf to avoid zeroing SONAME
This patch is a copy of the upstream PR NixOS/patchelf#171. This fixes a bug in patchelf which causes an SONAME entry filled with 'X' values.
1 parent 97c8470 commit 08c172a

File tree

3 files changed

+32
-6
lines changed

3 files changed

+32
-6
lines changed

docker/build_scripts/build.sh

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -142,12 +142,8 @@ export SSL_CERT_FILE=/opt/_internal/certs.pem
142142
# Now we can delete our built OpenSSL headers/static libs since we've linked everything we need
143143
rm -rf /usr/local/ssl
144144

145-
# Install patchelf (latest with unreleased bug fixes)
146-
curl -fsSL -o patchelf.tar.gz https://github.com/NixOS/patchelf/archive/$PATCHELF_VERSION.tar.gz
147-
check_sha256sum patchelf.tar.gz $PATCHELF_HASH
148-
tar -xzf patchelf.tar.gz
149-
(cd patchelf-$PATCHELF_VERSION && ./bootstrap.sh && do_standard_install)
150-
rm -rf patchelf.tar.gz patchelf-$PATCHELF_VERSION
145+
# Install patchelf (latest with unreleased bug fixes) and apply our patches
146+
build_patchelf $PATCHELF_VERSION $PATCHELF_HASH
151147

152148
ln -s $PY37_BIN/auditwheel /usr/local/bin/auditwheel
153149

docker/build_scripts/build_utils.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,3 +271,14 @@ function build_libxcrypt {
271271
rm -rf /usr/lib/libcrypt.a /usr/lib/libcrypt.so
272272
rm -rf /usr/lib64/libcrypt.a /usr/lib64/libcrypt.so
273273
}
274+
275+
function build_patchelf {
276+
local patchelf_version=$1
277+
local patchelf_hash=$2
278+
local src_dir=$(dirname $(readlink -f "${BASH_SOURCE[0]}"))
279+
curl -fsSL -o patchelf.tar.gz https://github.com/NixOS/patchelf/archive/$patchelf_version.tar.gz
280+
check_sha256sum patchelf.tar.gz $patchelf_hash
281+
tar -xzf patchelf.tar.gz
282+
(cd patchelf-$patchelf_version && patch -p1 -i "$src_dir"/patches/patchelf-remove-zeroing.diff && ./bootstrap.sh && do_standard_install)
283+
rm -rf patchelf.tar.gz patchelf-$patchelf_version
284+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Patch from https://github.com/NixOS/patchelf/pull/171
2+
diff --git a/src/patchelf.cc b/src/patchelf.cc
3+
index 0b4965a..592799d 100644
4+
--- a/src/patchelf.cc
5+
+++ b/src/patchelf.cc
6+
@@ -1074,13 +1074,6 @@ void ElfFile<ElfFileParamNames>::modifySoname(sonameMode op, const std::string &
7+
return;
8+
}
9+
10+
- /* Zero out the previous SONAME */
11+
- unsigned int sonameSize = 0;
12+
- if (soname) {
13+
- sonameSize = strlen(soname);
14+
- memset(soname, 'X', sonameSize);
15+
- }
16+
-
17+
debug("new SONAME is '%s'\n", newSoname.c_str());
18+
19+
/* Grow the .dynstr section to make room for the new SONAME. */

0 commit comments

Comments
 (0)