From 8fb9c6c3a676628ac74f6867f7754ac6809a49e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A1szl=C3=B3=20Kiss=20Koll=C3=A1r?= Date: Sat, 25 Apr 2020 12:39:37 +0100 Subject: [PATCH] Apply patch in patchelf to avoid zeroing SONAME (#549) This patch is a copy of the upstream PR https://github.com/NixOS/patchelf/pull/171. This fixes a bug in patchelf which causes an SONAME entry filled with 'X' values. --- docker/build_scripts/build.sh | 8 ++------ docker/build_scripts/build_utils.sh | 11 +++++++++++ .../patches/patchelf-remove-zeroing.diff | 19 +++++++++++++++++++ 3 files changed, 32 insertions(+), 6 deletions(-) create mode 100644 docker/build_scripts/patches/patchelf-remove-zeroing.diff diff --git a/docker/build_scripts/build.sh b/docker/build_scripts/build.sh index b2ea7680..90de6ea3 100755 --- a/docker/build_scripts/build.sh +++ b/docker/build_scripts/build.sh @@ -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 diff --git a/docker/build_scripts/build_utils.sh b/docker/build_scripts/build_utils.sh index 03c95a25..7c5942c8 100755 --- a/docker/build_scripts/build_utils.sh +++ b/docker/build_scripts/build_utils.sh @@ -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 +} diff --git a/docker/build_scripts/patches/patchelf-remove-zeroing.diff b/docker/build_scripts/patches/patchelf-remove-zeroing.diff new file mode 100644 index 00000000..6d64491a --- /dev/null +++ b/docker/build_scripts/patches/patchelf-remove-zeroing.diff @@ -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::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. */