Skip to content

Commit

Permalink
Apply patch in patchelf to avoid zeroing SONAME (#549)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
lkollar authored Apr 25, 2020
1 parent 2fd435d commit 8fb9c6c
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 6 deletions.
8 changes: 2 additions & 6 deletions docker/build_scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -140,12 +140,8 @@ ln -s $($PY37_BIN/python -c 'import certifi; print(certifi.where())') \
export SSL_CERT_FILE=/opt/_internal/certs.pem


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

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

Expand Down
11 changes: 11 additions & 0 deletions docker/build_scripts/build_utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -189,3 +189,14 @@ function build_libxcrypt {
rm -rf /usr/include/crypt.h
rm -rf /usr/lib64/libcrypt.a /usr/lib64/libcrypt.so
}

function build_patchelf {
local patchelf_version=$1
local patchelf_hash=$2
local src_dir=$(dirname $(readlink -f "${BASH_SOURCE[0]}"))
curl -fsSL -o patchelf.tar.gz https://github.com/NixOS/patchelf/archive/$patchelf_version.tar.gz
check_sha256sum patchelf.tar.gz $patchelf_hash
tar -xzf patchelf.tar.gz
(cd patchelf-$patchelf_version && patch -p1 -i "$src_dir"/patches/patchelf-remove-zeroing.diff && ./bootstrap.sh && do_standard_install)
rm -rf patchelf.tar.gz patchelf-$patchelf_version
}
19 changes: 19 additions & 0 deletions docker/build_scripts/patches/patchelf-remove-zeroing.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Patch from https://github.com/NixOS/patchelf/pull/171
diff --git a/src/patchelf.cc b/src/patchelf.cc
index 0b4965a..592799d 100644
--- a/src/patchelf.cc
+++ b/src/patchelf.cc
@@ -1074,13 +1074,6 @@ void ElfFile<ElfFileParamNames>::modifySoname(sonameMode op, const std::string &
return;
}

- /* Zero out the previous SONAME */
- unsigned int sonameSize = 0;
- if (soname) {
- sonameSize = strlen(soname);
- memset(soname, 'X', sonameSize);
- }
-
debug("new SONAME is '%s'\n", newSoname.c_str());

/* Grow the .dynstr section to make room for the new SONAME. */

0 comments on commit 8fb9c6c

Please sign in to comment.