GNU bug report logs - #38055
patchelf: Assertion failed when setting interpreter

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: guix; Reported by: Ivan Vilata i Balaguer <ivan@HIDDEN>; Done: Efraim Flashner <efraim@HIDDEN>; Maintainer for guix is bug-guix@HIDDEN.

Message received at 38055-done <at> debbugs.gnu.org:


Received: (at 38055-done) by debbugs.gnu.org; 11 Nov 2019 15:31:39 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Nov 11 10:31:39 2019
Received: from localhost ([127.0.0.1]:55918 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1iUBf7-0000Zb-Fr
	for submit <at> debbugs.gnu.org; Mon, 11 Nov 2019 10:31:39 -0500
Received: from lev.selidor.net ([66.246.138.156]:51803)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <ivan@HIDDEN>) id 1iUBf4-0000Wd-Kj
 for 38055-done <at> debbugs.gnu.org; Mon, 11 Nov 2019 10:31:28 -0500
Received: from sax.terramar.selidor.net (unknown
 [IPv6:2600:3c03:e001:114e:949b:a9f2:7d01:abce])
 by lev.selidor.net (Postfix) with ESMTP id E8CE2CA1A;
 Mon, 11 Nov 2019 15:31:25 +0000 (UTC)
Received: by sax.terramar.selidor.net (Postfix, from userid 1000)
 id 6DF579A36DE; Mon, 11 Nov 2019 10:30:30 -0500 (EST)
Date: Mon, 11 Nov 2019 10:30:30 -0500
From: Ivan Vilata i Balaguer <ivan@HIDDEN>
To: Ivan Vilata i Balaguer <ivan@HIDDEN>
Subject: Re: none
Message-ID: <20191111153030.GP17621@HIDDEN>
References: <20191109182510.GA3954@E5400> <87k1873jjh.fsf@HIDDEN>
 <20191111092730.GF3954@E5400>
 <20191111151010.GO17621@HIDDEN>
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="JgQwtEuHJzHdouWu"
Content-Disposition: inline
Content-Transfer-Encoding: 8bit
In-Reply-To: <20191111151010.GO17621@HIDDEN>
User-Agent: Mutt/1.12.2 (2019-09-21)
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 38055-done
Cc: Ludovic =?iso-8859-1?Q?Court=E8s?= <ludo@HIDDEN>,
 Efraim Flashner <efraim@HIDDEN>, 38055-done <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)


--JgQwtEuHJzHdouWu
Content-Type: text/plain; charset=utf-8
Content-Disposition: inline
Content-Transfer-Encoding: 8bit

Ivan Vilata i Balaguer (2019-11-11 10:10:10 -0500) wrote:

> […] I'm still attaching it in case you're curious (of course I don't expect
> any of it to get merged `;)`). […]

Forgot the attachment… `:P`

-- 
Ivan Vilata i Balaguer -- https://elvil.net/

--JgQwtEuHJzHdouWu
Content-Type: text/plain; charset=utf-8
Content-Disposition: attachment;
	filename="0001-gnu-patchelf-Update-to-0.10.patch"
Content-Transfer-Encoding: 8bit

From 2e4cca87b865dbd26ee417775d543abab7ba4f53 Mon Sep 17 00:00:00 2001
From: Ivan Vilata-i-Balaguer <ivan@HIDDEN>
Date: Fri, 8 Nov 2019 13:59:53 -0500
Subject: [PATCH] gnu: patchelf: Update to 0.10.

Besides the update, the patches for "page size" and "rework for ARM" were
removed since they can no longer be applied to upstream source.

Also, the "no-rpath.sh" test was skipped since it would fail under Guix, see
<https://issues.guix.gnu.org/issue/38055>.

* gnu/packages/elf.scm (patchelf): Update to 0.10.
* gnu/packages/patches/patchelf-page-size.patch: Delete file.
* gnu/packages/patches/patchelf-rework-for-arm.patch: Delete file.
* gnu/packages/patches/patchelf-skip-no-rpath-test.patch: New file.
---
 gnu/packages/elf.scm                          |  25 +-
 gnu/packages/patches/patchelf-page-size.patch |  70 ---
 .../patches/patchelf-rework-for-arm.patch     | 473 ------------------
 .../patches/patchelf-skip-no-rpath-test.patch |  18 +
 4 files changed, 21 insertions(+), 565 deletions(-)
 delete mode 100644 gnu/packages/patches/patchelf-page-size.patch
 delete mode 100644 gnu/packages/patches/patchelf-rework-for-arm.patch
 create mode 100644 gnu/packages/patches/patchelf-skip-no-rpath-test.patch

diff --git a/gnu/packages/elf.scm b/gnu/packages/elf.scm
index 4f365cf205..28bdcedcd2 100644
--- a/gnu/packages/elf.scm
+++ b/gnu/packages/elf.scm
@@ -198,7 +198,7 @@ static analysis of the ELF binaries at hand.")
 (define-public patchelf
   (package
     (name "patchelf")
-    (version "0.8")
+    (version "0.10")
     (source (origin
              (method url-fetch)
              (uri (string-append
@@ -207,28 +207,9 @@ static analysis of the ELF binaries at hand.")
                    "/patchelf-" version ".tar.bz2"))
              (sha256
               (base32
-               "1rqpg84wrd3fa16wa9vqdvasnc05yz49w207cz1l0wrl4k8q97y9"))
-             (patches (search-patches "patchelf-page-size.patch"))))
+               "1wzwvnlyf853hw9zgqq5522bvf8gqadk8icgqa41a5n7593csw7n"))
+             (patches (search-patches "patchelf-skip-no-rpath-test.patch"))))
     (build-system gnu-build-system)
-
-    ;; XXX: The upstream 'patchelf' doesn't support ARM.  The only available
-    ;;      patch makes significant changes to the algorithm, possibly
-    ;;      introducing bugs.  So, we apply the patch only on ARM systems.
-    (inputs
-     (if (target-arm32?)
-         `(("patch/rework-for-arm" ,(search-patch
-                                     "patchelf-rework-for-arm.patch")))
-         '()))
-    (arguments
-     (if (target-arm32?)
-         `(#:phases
-           (modify-phases %standard-phases
-             (add-after 'unpack 'patch/rework-for-arm
-               (lambda* (#:key inputs #:allow-other-keys)
-                 (let ((patch-file (assoc-ref inputs "patch/rework-for-arm")))
-                   (invoke "patch" "--force" "-p1" "--input" patch-file))))))
-         '()))
-
     (home-page "https://nixos.org/patchelf.html")
     (synopsis "Modify the dynamic linker and RPATH of ELF executables")
     (description
diff --git a/gnu/packages/patches/patchelf-page-size.patch b/gnu/packages/patches/patchelf-page-size.patch
deleted file mode 100644
index 1c14047512..0000000000
--- a/gnu/packages/patches/patchelf-page-size.patch
+++ /dev/null
@@ -1,70 +0,0 @@
-Improve the determination of pageSize in patchelf.cc.
-
-Patch by Mark H Weaver <mhw@HIDDEN>.
-
---- patchelf/src/patchelf.cc.orig	1969-12-31 19:00:01.000000000 -0500
-+++ patchelf/src/patchelf.cc	2014-02-16 20:15:06.283203125 -0500
-@@ -21,11 +21,19 @@
- using namespace std;
- 
- 
--#ifdef MIPSEL
--/* The lemote fuloong 2f kernel defconfig sets a page size of 16KB */
--const unsigned int pageSize = 4096*4;
--#else
-+/* Note that some platforms support multiple page sizes.  Therefore,
-+   it is not enough to query the current page size.  'pageSize' must
-+   be the maximum architectural page size for the platform, which is
-+   typically defined in the corresponding ABI document.
-+
-+   XXX FIXME: This won't work when we're cross-compiling.  */
-+
-+#if defined __MIPSEL__ || defined __MIPSEB__ || defined __aarch64__
-+const unsigned int pageSize = 65536;
-+#elif defined __x86_64__ || defined __i386__ || defined __arm__
- const unsigned int pageSize = 4096;
-+#else
-+# error maximum architectural page size unknown for this platform
- #endif
- 
- 
---- patchelf/tests/no-rpath.sh.orig	2014-01-14 08:17:47.000000000 -0500
-+++ patchelf/tests/no-rpath.sh	2015-01-06 18:31:53.418172797 -0500
-@@ -1,23 +1,23 @@
- #! /bin/sh -e
- SCRATCH=scratch/$(basename $0 .sh)
- 
--rm -rf ${SCRATCH}
--mkdir -p ${SCRATCH}
-+if [ "$(uname -m)" = i686 -a "$(uname -s)" = Linux ]; then
-+    rm -rf ${SCRATCH}
-+    mkdir -p ${SCRATCH}
- 
--cp ${srcdir}/no-rpath ${SCRATCH}/
-+    cp ${srcdir}/no-rpath ${SCRATCH}/
- 
--oldRPath=$(../src/patchelf --print-rpath ${SCRATCH}/no-rpath)
--if test -n "$oldRPath"; then exit 1; fi
--../src/patchelf \
--  --set-interpreter "$(../src/patchelf --print-interpreter ../src/patchelf)" \
--  --set-rpath /foo:/bar:/xxxxxxxxxxxxxxx ${SCRATCH}/no-rpath
-+    oldRPath=$(../src/patchelf --print-rpath ${SCRATCH}/no-rpath)
-+    if test -n "$oldRPath"; then exit 1; fi
-+    ../src/patchelf \
-+      --set-interpreter "$(../src/patchelf --print-interpreter ../src/patchelf)" \
-+      --set-rpath /foo:/bar:/xxxxxxxxxxxxxxx ${SCRATCH}/no-rpath
- 
--newRPath=$(../src/patchelf --print-rpath ${SCRATCH}/no-rpath)
--if ! echo "$newRPath" | grep -q '/foo:/bar'; then
--    echo "incomplete RPATH"
--    exit 1
--fi
-+    newRPath=$(../src/patchelf --print-rpath ${SCRATCH}/no-rpath)
-+    if ! echo "$newRPath" | grep -q '/foo:/bar'; then
-+        echo "incomplete RPATH"
-+        exit 1
-+    fi
- 
--if [ "$(uname -m)" = i686 -a "$(uname -s)" = Linux ]; then
-     cd ${SCRATCH} && ./no-rpath
- fi
diff --git a/gnu/packages/patches/patchelf-rework-for-arm.patch b/gnu/packages/patches/patchelf-rework-for-arm.patch
deleted file mode 100644
index 6f4eb8f72b..0000000000
--- a/gnu/packages/patches/patchelf-rework-for-arm.patch
+++ /dev/null
@@ -1,473 +0,0 @@
-Rework the growing algorithm in patchelf to support ARM systems.
-See <https://github.com/NixOS/patchelf/issues/8>.
-This patch copied from:
-<https://github.com/sriemer/patchelf/commit/0a96239cea6b97b9a0fff80da576e58ca2dfb2a2>
-
-From 0a96239cea6b97b9a0fff80da576e58ca2dfb2a2 Mon Sep 17 00:00:00 2001
-From: Sebastian Parschauer <s.parschauer@HIDDEN>
-Date: Sat, 28 Jun 2014 01:24:57 +0200
-Subject: [PATCH] Rework the growing algorithm
-
-On ARM systems there is no space in virtual memory for another LOAD
-area in front of the code LOAD area. So insert data to its end
-instead. At this location there should be enough space in virtual
-memory due to alignment. We can extend it until the end of the
-alignment but the file shift may be greater as it must be aligned
-to the page size. Do the same for the data LOAD area.
----
- src/patchelf.cc | 357 ++++++++++++++++++++++----------------------------------
- 1 file changed, 142 insertions(+), 215 deletions(-)
-
-diff --git a/src/patchelf.cc b/src/patchelf.cc
-index dcbfd38..4fce9e6 100644
---- a/src/patchelf.cc
-+++ b/src/patchelf.cc
-@@ -116,7 +116,11 @@ private:
- 
-     void sortShdrs();
- 
--    void shiftFile(unsigned int extraPages, Elf_Addr startPage);
-+    void shiftFileSingle(size_t fileShift, Elf_Off insertOff);
-+
-+    void shiftFile(size_t neededCode, size_t neededData,
-+                   Elf_Off codeOff[], Elf_Off dataOff[],
-+                   Elf_Addr *codePage, Elf_Addr *dataPage);
- 
-     string getSectionName(const Elf_Shdr & shdr);
- 
-@@ -130,13 +134,11 @@ private:
-         unsigned int size);
- 
-     void writeReplacedSections(Elf_Off & curOff,
--        Elf_Addr startAddr, Elf_Off startOffset);
-+        Elf_Addr startAddr, Elf_Off startOffset, bool isData);
- 
-     void rewriteHeaders(Elf_Addr phdrAddress);
- 
--    void rewriteSectionsLibrary();
--
--    void rewriteSectionsExecutable();
-+    void rewriteSectionsBinary();
- 
- public:
- 
-@@ -391,46 +393,119 @@ static unsigned int roundUp(unsigned int n, unsigned int m)
- 
- 
- template<ElfFileParams>
--void ElfFile<ElfFileParamNames>::shiftFile(unsigned int extraPages, Elf_Addr startPage)
-+void ElfFile<ElfFileParamNames>::shiftFileSingle(size_t fileShift,
-+        Elf_Off insertOff)
- {
--    /* Move the entire contents of the file `extraPages' pages
--       further. */
-     unsigned int oldSize = fileSize;
--    unsigned int shift = extraPages * pageSize;
--    growFile(fileSize + extraPages * pageSize);
--    memmove(contents + extraPages * pageSize, contents, oldSize);
--    memset(contents + sizeof(Elf_Ehdr), 0, shift - sizeof(Elf_Ehdr));
-+
-+    /* Grow at the end */
-+    growFile(fileSize + fileShift);
-+
-+    /* move the data from the insertion point
-+       to the end and zero inserted space */
-+    memmove(contents + insertOff + fileShift,
-+            contents + insertOff, oldSize - insertOff);
-+    memset(contents + insertOff, 0, fileShift);
- 
-     /* Adjust the ELF header. */
-     wri(hdr->e_phoff, sizeof(Elf_Ehdr));
--    wri(hdr->e_shoff, rdi(hdr->e_shoff) + shift);
-+    if (rdi(hdr->e_shoff) >= insertOff)
-+        wri(hdr->e_shoff, rdi(hdr->e_shoff) + fileShift);
- 
-     /* Update the offsets in the section headers. */
--    for (int i = 1; i < rdi(hdr->e_shnum); ++i)
--        wri(shdrs[i].sh_offset, rdi(shdrs[i].sh_offset) + shift);
-+    for (int i = 1; i < rdi(hdr->e_shnum); ++i) {
-+        if (rdi(shdrs[i].sh_offset) >= insertOff)
-+            wri(shdrs[i].sh_offset, rdi(shdrs[i].sh_offset) + fileShift);
-+    }
- 
-     /* Update the offsets in the program headers. */
-     for (int i = 0; i < rdi(hdr->e_phnum); ++i) {
--        wri(phdrs[i].p_offset, rdi(phdrs[i].p_offset) + shift);
--        if (rdi(phdrs[i].p_align) != 0 &&
--            (rdi(phdrs[i].p_vaddr) - rdi(phdrs[i].p_offset)) % rdi(phdrs[i].p_align) != 0) {
--            debug("changing alignment of program header %d from %d to %d\n", i,
--                rdi(phdrs[i].p_align), pageSize);
--            wri(phdrs[i].p_align, pageSize);
-+        if (rdi(phdrs[i].p_offset) >= insertOff)
-+            wri(phdrs[i].p_offset, rdi(phdrs[i].p_offset) + fileShift);
-+        /* Check for ELF load command alignment issue the same
-+           way as glibc/elf/dl-load.c does. This gives us the
-+           chance to run an interpreter explicitly. */
-+        if (rdi(phdrs[i].p_type) == PT_LOAD && ((rdi(phdrs[i].p_vaddr) -
-+          rdi(phdrs[i].p_offset)) & (rdi(phdrs[i].p_align) - 1)) != 0) {
-+             debug("changing alignment of program header %d from %d to %d\n",
-+                   i, rdi(phdrs[i].p_align), pageSize);
-+             wri(phdrs[i].p_align, pageSize);
-         }
-     }
-+}
-+
-+template<ElfFileParams>
-+void ElfFile<ElfFileParamNames>::shiftFile(size_t neededCode,
-+        size_t neededData, Elf_Off codeOff[], Elf_Off dataOff[],
-+        Elf_Addr *codePage, Elf_Addr *dataPage)
-+{
-+    /* Move some contents of the file further. The binary has one LOAD area
-+     * for code and one for data. There is virtual memory space between
-+     * these which we can use due to alignment.
-+     */
-+    unsigned int memShift = neededCode;
-+    unsigned int fileShift = roundUp(neededCode, pageSize);
-+    unsigned int maxMemShift = 0;
-+
-+    if (neededCode > 0) {
-+        /* find the LOAD program header for code and extend it */
-+        for (int i = 0; i < rdi(hdr->e_phnum); ++i) {
-+            if (rdi(phdrs[i].p_type) == PT_LOAD &&
-+              rdi(phdrs[i].p_flags) & PF_X) {
-+                codeOff[1] = rdi(phdrs[i].p_filesz);
-+                codeOff[0] = codeOff[1] + rdi(phdrs[i].p_offset);
-+                maxMemShift = rdi(phdrs[i].p_memsz) % rdi(phdrs[i].p_align);
-+                if (maxMemShift == 0)
-+                    continue;
-+                maxMemShift = rdi(phdrs[i].p_align) - maxMemShift;
-+                if (maxMemShift == 0 || memShift > maxMemShift)
-+                    continue;
-+                *codePage = rdi(phdrs[i].p_vaddr);
-+                wri(phdrs[i].p_filesz, rdi(phdrs[i].p_filesz) + memShift);
-+                wri(phdrs[i].p_memsz, rdi(phdrs[i].p_memsz) + memShift);
-+                break;
-+            }
-+        }
-+        debug("codeOff: %#lx, memShift: %d, maxMemShift: %d, fileShift: %d\n",
-+              codeOff[1], memShift, maxMemShift, fileShift);
-+        if (codeOff[1] == 0 || maxMemShift == 0)
-+            goto out;
-+
-+        shiftFileSingle(fileShift, codeOff[0]);
-+    }
-+
-+    /* +++ Do the same for the data LOAD area  +++ */
-+    memShift = neededData;
-+    fileShift = roundUp(neededData, pageSize);
-+    maxMemShift = 0;
-+    if (neededData > 0) {
-+        /* find the LOAD program header for data and extend it */
-+        for (int i = 0; i < rdi(hdr->e_phnum); ++i) {
-+            if (rdi(phdrs[i].p_type) == PT_LOAD &&
-+              rdi(phdrs[i].p_flags) & PF_W) {
-+                dataOff[1] = rdi(phdrs[i].p_filesz);
-+                dataOff[0] = dataOff[1] + rdi(phdrs[i].p_offset);
-+                maxMemShift = rdi(phdrs[i].p_memsz) % rdi(phdrs[i].p_align);
-+                if (maxMemShift == 0)
-+                    continue;
-+                maxMemShift = rdi(phdrs[i].p_align) - maxMemShift;
-+                if (maxMemShift == 0 || memShift > maxMemShift)
-+                    continue;
-+                *dataPage = rdi(phdrs[i].p_vaddr);
-+                wri(phdrs[i].p_filesz, rdi(phdrs[i].p_filesz) + memShift);
-+                wri(phdrs[i].p_memsz, rdi(phdrs[i].p_memsz) + memShift);
-+                break;
-+            }
-+        }
-+        debug("dataOff: %#lx, memShift: %d, maxMemShift: %d, fileShift: %d\n",
-+              dataOff[1], memShift, maxMemShift, fileShift);
-+        if (dataOff[1] == 0 || maxMemShift == 0)
-+            goto out;
- 
--    /* Add a segment that maps the new program/section headers and
--       PT_INTERP segment into memory.  Otherwise glibc will choke. */
--    phdrs.resize(rdi(hdr->e_phnum) + 1);
--    wri(hdr->e_phnum, rdi(hdr->e_phnum) + 1);
--    Elf_Phdr & phdr = phdrs[rdi(hdr->e_phnum) - 1];
--    wri(phdr.p_type, PT_LOAD);
--    wri(phdr.p_offset, 0);
--    wri(phdr.p_vaddr, wri(phdr.p_paddr, startPage));
--    wri(phdr.p_filesz, wri(phdr.p_memsz, shift));
--    wri(phdr.p_flags, PF_R | PF_W);
--    wri(phdr.p_align, pageSize);
-+        shiftFileSingle(fileShift, dataOff[0]);
-+    }
-+out:
-+    return;
- }
- 
- 
-@@ -491,7 +566,7 @@ string & ElfFile<ElfFileParamNames>::replaceSection(const SectionName & sectionN
- 
- template<ElfFileParams>
- void ElfFile<ElfFileParamNames>::writeReplacedSections(Elf_Off & curOff,
--    Elf_Addr startAddr, Elf_Off startOffset)
-+    Elf_Addr startAddr, Elf_Off startOffset, bool isData = false)
- {
-     /* Overwrite the old section contents with 'X's.  Do this
-        *before* writing the new section contents (below) to prevent
-@@ -501,6 +576,9 @@ void ElfFile<ElfFileParamNames>::writeReplacedSections(Elf_Off & curOff,
-     {
-         string sectionName = i->first;
-         Elf_Shdr & shdr = findSection(sectionName);
-+        if ((!isData && rdi(shdr.sh_flags) & SHF_WRITE) ||
-+         (isData && ~(rdi(shdr.sh_flags)) & SHF_WRITE))
-+            continue;
-         memset(contents + rdi(shdr.sh_offset), 'X', rdi(shdr.sh_size));
-     }
- 
-@@ -509,6 +587,9 @@ void ElfFile<ElfFileParamNames>::writeReplacedSections(Elf_Off & curOff,
-     {
-         string sectionName = i->first;
-         Elf_Shdr & shdr = findSection(sectionName);
-+        if ((!isData && rdi(shdr.sh_flags) & SHF_WRITE) ||
-+         (isData && ~(rdi(shdr.sh_flags)) & SHF_WRITE))
-+            continue;
-         debug("rewriting section `%s' from offset 0x%x (size %d) to offset 0x%x (size %d)\n",
-             sectionName.c_str(), rdi(shdr.sh_offset), rdi(shdr.sh_size), curOff, i->second.size());
- 
-@@ -546,201 +627,47 @@ void ElfFile<ElfFileParamNames>::writeReplacedSections(Elf_Off & curOff,
-         curOff += roundUp(i->second.size(), sectionAlignment);
-     }
- 
--    replacedSections.clear();
-+    if (isData)
-+        replacedSections.clear();
- }
- 
- 
- template<ElfFileParams>
--void ElfFile<ElfFileParamNames>::rewriteSectionsLibrary()
-+void ElfFile<ElfFileParamNames>::rewriteSectionsBinary()
- {
--    /* For dynamic libraries, we just place the replacement sections
--       at the end of the file.  They're mapped into memory by a
--       PT_LOAD segment located directly after the last virtual address
--       page of other segments. */
--    Elf_Addr startPage = 0;
--    for (unsigned int i = 0; i < phdrs.size(); ++i) {
--        Elf_Addr thisPage = roundUp(rdi(phdrs[i].p_vaddr) + rdi(phdrs[i].p_memsz), pageSize);
--        if (thisPage > startPage) startPage = thisPage;
--    }
--
--    debug("last page is 0x%llx\n", (unsigned long long) startPage);
-+    Elf_Off codeOff[2] = {0}, dataOff[2] = {0};
-+    Elf_Addr codePage = 0, dataPage = 0;
-+    size_t neededCode = 0, neededData = 0, oldCode = 0, oldData = 0;
-+    Elf_Shdr shdr = findSection(".text");
-+    Elf_Addr firstPage = rdi(shdr.sh_addr) - rdi(shdr.sh_offset);
- 
-+    debug("first page is 0x%llx\n", (unsigned long long) firstPage);
- 
--    /* Compute the total space needed for the replaced sections and
--       the program headers. */
--    off_t neededSpace = (phdrs.size() + 1) * sizeof(Elf_Phdr);
-+    /* Compute the total space needed for the replaced sections */
-     for (ReplacedSections::iterator i = replacedSections.begin();
--         i != replacedSections.end(); ++i)
--        neededSpace += roundUp(i->second.size(), sectionAlignment);
--    debug("needed space is %d\n", neededSpace);
--
--
--    size_t startOffset = roundUp(fileSize, pageSize);
--
--    growFile(startOffset + neededSpace);
--
--
--    /* Even though this file is of type ET_DYN, it could actually be
--       an executable.  For instance, Gold produces executables marked
--       ET_DYN.  In that case we can still hit the kernel bug that
--       necessitated rewriteSectionsExecutable().  However, such
--       executables also tend to start at virtual address 0, so
--       rewriteSectionsExecutable() won't work because it doesn't have
--       any virtual address space to grow downwards into.  As a
--       workaround, make sure that the virtual address of our new
--       PT_LOAD segment relative to the first PT_LOAD segment is equal
--       to its offset; otherwise we hit the kernel bug.  This may
--       require creating a hole in the executable.  The bigger the size
--       of the uninitialised data segment, the bigger the hole. */
--    if (isExecutable) {
--        if (startOffset >= startPage) {
--            debug("shifting new PT_LOAD segment by %d bytes to work around a Linux kernel bug\n", startOffset - startPage);
--        } else {
--            size_t hole = startPage - startOffset;
--            /* Print a warning, because the hole could be very big. */
--            fprintf(stderr, "warning: working around a Linux kernel bug by creating a hole of %zu bytes in ‘%s’\n", hole, fileName.c_str());
--            assert(hole % pageSize == 0);
--            /* !!! We could create an actual hole in the file here,
--               but it's probably not worth the effort. */
--            growFile(fileSize + hole);
--            startOffset += hole;
--        }
--        startPage = startOffset;
--    }
--
--
--    /* Add a segment that maps the replaced sections and program
--       headers into memory. */
--    phdrs.resize(rdi(hdr->e_phnum) + 1);
--    wri(hdr->e_phnum, rdi(hdr->e_phnum) + 1);
--    Elf_Phdr & phdr = phdrs[rdi(hdr->e_phnum) - 1];
--    wri(phdr.p_type, PT_LOAD);
--    wri(phdr.p_offset, startOffset);
--    wri(phdr.p_vaddr, wri(phdr.p_paddr, startPage));
--    wri(phdr.p_filesz, wri(phdr.p_memsz, neededSpace));
--    wri(phdr.p_flags, PF_R | PF_W);
--    wri(phdr.p_align, pageSize);
--
--
--    /* Write out the replaced sections. */
--    Elf_Off curOff = startOffset + phdrs.size() * sizeof(Elf_Phdr);
--    writeReplacedSections(curOff, startPage, startOffset);
--    assert((off_t) curOff == startOffset + neededSpace);
--
--
--    /* Move the program header to the start of the new area. */
--    wri(hdr->e_phoff, startOffset);
--
--    rewriteHeaders(startPage);
--}
--
--
--template<ElfFileParams>
--void ElfFile<ElfFileParamNames>::rewriteSectionsExecutable()
--{
--    /* Sort the sections by offset, otherwise we won't correctly find
--       all the sections before the last replaced section. */
--    sortShdrs();
--
--
--    /* What is the index of the last replaced section? */
--    unsigned int lastReplaced = 0;
--    for (unsigned int i = 1; i < rdi(hdr->e_shnum); ++i) {
--        string sectionName = getSectionName(shdrs[i]);
--        if (replacedSections.find(sectionName) != replacedSections.end()) {
--            debug("using replaced section `%s'\n", sectionName.c_str());
--            lastReplaced = i;
--        }
--    }
--
--    assert(lastReplaced != 0);
--
--    debug("last replaced is %d\n", lastReplaced);
--
--    /* Try to replace all sections before that, as far as possible.
--       Stop when we reach an irreplacable section (such as one of type
--       SHT_PROGBITS).  These cannot be moved in virtual address space
--       since that would invalidate absolute references to them. */
--    assert(lastReplaced + 1 < shdrs.size()); /* !!! I'm lazy. */
--    size_t startOffset = rdi(shdrs[lastReplaced + 1].sh_offset);
--    Elf_Addr startAddr = rdi(shdrs[lastReplaced + 1].sh_addr);
--    string prevSection;
--    for (unsigned int i = 1; i <= lastReplaced; ++i) {
--        Elf_Shdr & shdr(shdrs[i]);
--        string sectionName = getSectionName(shdr);
--        debug("looking at section `%s'\n", sectionName.c_str());
--        /* !!! Why do we stop after a .dynstr section? I can't
--           remember! */
--        if ((rdi(shdr.sh_type) == SHT_PROGBITS && sectionName != ".interp")
--            || prevSection == ".dynstr")
--        {
--            startOffset = rdi(shdr.sh_offset);
--            startAddr = rdi(shdr.sh_addr);
--            lastReplaced = i - 1;
--            break;
-+         i != replacedSections.end(); ++i) {
-+        shdr = findSection(i->first);
-+        if (rdi(shdr.sh_flags) & SHF_WRITE) {
-+            oldData += rdi(shdr.sh_size);
-+            neededData += roundUp(i->second.size(), sectionAlignment);
-         } else {
--            if (replacedSections.find(sectionName) == replacedSections.end()) {
--                debug("replacing section `%s' which is in the way\n", sectionName.c_str());
--                replaceSection(sectionName, rdi(shdr.sh_size));
--            }
-+            oldCode += rdi(shdr.sh_size);
-+            neededCode += roundUp(i->second.size(), sectionAlignment);
-         }
--        prevSection = sectionName;
-     }
- 
--    debug("first reserved offset/addr is 0x%x/0x%llx\n",
--        startOffset, (unsigned long long) startAddr);
--
--    assert(startAddr % pageSize == startOffset % pageSize);
--    Elf_Addr firstPage = startAddr - startOffset;
--    debug("first page is 0x%llx\n", (unsigned long long) firstPage);
--
--    /* Right now we assume that the section headers are somewhere near
--       the end, which appears to be the case most of the time.
--       Therefore they're not accidentally overwritten by the replaced
--       sections. !!!  Fix this. */
--    assert((off_t) rdi(hdr->e_shoff) >= startOffset);
--
--
--    /* Compute the total space needed for the replaced sections, the
--       ELF header, and the program headers. */
--    size_t neededSpace = sizeof(Elf_Ehdr) + phdrs.size() * sizeof(Elf_Phdr);
--    for (ReplacedSections::iterator i = replacedSections.begin();
--         i != replacedSections.end(); ++i)
--        neededSpace += roundUp(i->second.size(), sectionAlignment);
--
--    debug("needed space is %d\n", neededSpace);
--
--    /* If we need more space at the start of the file, then grow the
--       file by the minimum number of pages and adjust internal
--       offsets. */
--    if (neededSpace > startOffset) {
--
--        /* We also need an additional program header, so adjust for that. */
--        neededSpace += sizeof(Elf_Phdr);
--        debug("needed space is %d\n", neededSpace);
--
--        unsigned int neededPages = roundUp(neededSpace - startOffset, pageSize) / pageSize;
--        debug("needed pages is %d\n", neededPages);
--        if (neededPages * pageSize > firstPage)
--            error("virtual address space underrun!");
--
--        firstPage -= neededPages * pageSize;
--        startOffset += neededPages * pageSize;
--
--        shiftFile(neededPages, firstPage);
--    }
--
--
--    /* Clear out the free space. */
--    Elf_Off curOff = sizeof(Elf_Ehdr) + phdrs.size() * sizeof(Elf_Phdr);
--    debug("clearing first %d bytes\n", startOffset - curOff);
--    memset(contents + curOff, 0, startOffset - curOff);
-+    debug("needed space is C: %d, D: %d\n", neededCode, neededData);
- 
-+    /* If we need more space within the file, then grow the
-+       file and adjust internal offsets. */
-+    shiftFile(neededCode, neededData, codeOff, dataOff, &codePage,
-+              &dataPage);
-+    assert(codeOff[0] > 0);
- 
-     /* Write out the replaced sections. */
--    writeReplacedSections(curOff, firstPage, 0);
--    assert((off_t) curOff == neededSpace);
--
-+    debug("codePage: %#lx, dataPage: %#lx\n", codePage, dataPage);
-+    writeReplacedSections(codeOff[0], codePage + codeOff[1], codeOff[0]);
-+    writeReplacedSections(dataOff[0], dataPage + dataOff[1], dataOff[0], true);
- 
-     rewriteHeaders(firstPage + rdi(hdr->e_phoff));
- }
-@@ -758,10 +685,10 @@ void ElfFile<ElfFileParamNames>::rewriteSections()
- 
-     if (rdi(hdr->e_type) == ET_DYN) {
-         debug("this is a dynamic library\n");
--        rewriteSectionsLibrary();
-+        rewriteSectionsBinary();
-     } else if (rdi(hdr->e_type) == ET_EXEC) {
-         debug("this is an executable\n");
--        rewriteSectionsExecutable();
-+        rewriteSectionsBinary();
-     } else error("unknown ELF type");
- }
- 
--- 
-2.1.2
-
diff --git a/gnu/packages/patches/patchelf-skip-no-rpath-test.patch b/gnu/packages/patches/patchelf-skip-no-rpath-test.patch
new file mode 100644
index 0000000000..7b49f7aead
--- /dev/null
+++ b/gnu/packages/patches/patchelf-skip-no-rpath-test.patch
@@ -0,0 +1,18 @@
+diff -Nur patchelf-0.10.orig/tests/no-rpath.sh patchelf-0.10/tests/no-rpath.sh
+--- patchelf-0.10.orig/tests/no-rpath.sh	1969-12-31 19:00:01.000000000 -0500
++++ patchelf-0.10/tests/no-rpath.sh	2019-11-08 13:46:44.132511756 -0500
+@@ -1,4 +1,14 @@
+ #! /bin/sh -e
++# This test would fail under Guix since gcc always adds RUNPATH entries,
++# so `$oldRPath` below for the built `no-rpath` binary is never empty.
++#
++# Hopefully the `no-rpath-prebuild.sh` test does include a binary
++# for this architecture without a RUNPATH, and this test is redundant,
++# so just skip it (see "Scripts-based Testsuites" in Automake's manual).
++#
++# See <https://issues.guix.gnu.org/issue/38055> for more info.
++exit 77
++
+ SCRATCH=scratch/$(basename $0 .sh)
+ 
+ rm -rf ${SCRATCH}
-- 
2.23.0


--JgQwtEuHJzHdouWu--




Information forwarded to bug-guix@HIDDEN:
bug#38055; Package guix. Full text available.

Message received at 38055-done <at> debbugs.gnu.org:


Received: (at 38055-done) by debbugs.gnu.org; 11 Nov 2019 15:11:09 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Nov 11 10:11:09 2019
Received: from localhost ([127.0.0.1]:55904 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1iUBLQ-0005LL-Ds
	for submit <at> debbugs.gnu.org; Mon, 11 Nov 2019 10:11:09 -0500
Received: from lev.selidor.net ([66.246.138.156]:53573)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <ivan@HIDDEN>) id 1iUBLO-0005LC-Gx
 for 38055-done <at> debbugs.gnu.org; Mon, 11 Nov 2019 10:11:07 -0500
Received: from sax.terramar.selidor.net (unknown
 [IPv6:2600:3c03:e001:114e:949b:a9f2:7d01:abce])
 by lev.selidor.net (Postfix) with ESMTP id EF9DECA1A;
 Mon, 11 Nov 2019 15:11:05 +0000 (UTC)
Received: by sax.terramar.selidor.net (Postfix, from userid 1000)
 id 73E049A36DE; Mon, 11 Nov 2019 10:10:10 -0500 (EST)
Date: Mon, 11 Nov 2019 10:10:10 -0500
From: Ivan Vilata i Balaguer <ivan@HIDDEN>
To: Efraim Flashner <efraim@HIDDEN>
Subject: Re: none
Message-ID: <20191111151010.GO17621@HIDDEN>
References: <20191109182510.GA3954@E5400> <87k1873jjh.fsf@HIDDEN>
 <20191111092730.GF3954@E5400>
MIME-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
Content-Disposition: inline
Content-Transfer-Encoding: 8bit
In-Reply-To: <20191111092730.GF3954@E5400>
User-Agent: Mutt/1.12.2 (2019-09-21)
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 38055-done
Cc: Ludovic =?iso-8859-1?Q?Court=E8s?= <ludo@HIDDEN>,
 38055-done <at> debbugs.gnu.org, Ivan Vilata i Balaguer <ivan@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Efraim Flashner (2019-11-11 11:27:30 +0200) wrote:

> Some inline comments added. Patch pushed.

Wow, thank you so much for taking care of this!  I did prepare a patch on
Friday but I didn't have the time to send it, plus it pales in comparison to
Efraim's and it also had the `ipfs` binary segfault after patching.  I'm still
attaching it in case you're curious (of course I don't expect any of it to get
merged`;)`).

I'll try to find a moment to test your patch and see if the `ipfs` binary
doesn't segfault, then report back.

Thanks again!

-- 
Ivan Vilata i Balaguer -- https://elvil.net/




Information forwarded to bug-guix@HIDDEN:
bug#38055; Package guix. Full text available.

Message received at 38055-done <at> debbugs.gnu.org:


Received: (at 38055-done) by debbugs.gnu.org; 11 Nov 2019 09:28:11 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Nov 11 04:28:10 2019
Received: from localhost ([127.0.0.1]:53115 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1iU5zV-00076N-R9
	for submit <at> debbugs.gnu.org; Mon, 11 Nov 2019 04:28:10 -0500
Received: from flashner.co.il ([178.62.234.194]:56902)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <efraim@HIDDEN>) id 1iU5zU-000765-8o
 for 38055-done <at> debbugs.gnu.org; Mon, 11 Nov 2019 04:28:08 -0500
Received: from localhost (unknown [141.226.13.108])
 by flashner.co.il (Postfix) with ESMTPSA id 4D7E0400E5;
 Mon, 11 Nov 2019 09:28:02 +0000 (UTC)
Date: Mon, 11 Nov 2019 11:27:30 +0200
From: Efraim Flashner <efraim@HIDDEN>
To: Ludovic =?utf-8?Q?Court=C3=A8s?= <ludo@HIDDEN>
Subject: Re: none
Message-ID: <20191111092730.GF3954@E5400>
References: <20191109182510.GA3954@E5400>
 <87k1873jjh.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: multipart/signed; micalg=pgp-sha512;
 protocol="application/pgp-signature"; boundary="p7qwJlK53pWzbayA"
Content-Disposition: inline
In-Reply-To: <87k1873jjh.fsf@HIDDEN>
X-PGP-Key-ID: 0x41AAE7DCCA3D8351
X-PGP-Key: https://flashner.co.il/~efraim/efraim_flashner.asc
X-PGP-Fingerprint: A28B F40C 3E55 1372 662D  14F7 41AA E7DC CA3D 8351
User-Agent: Mutt/1.12.2 (2019-09-21)
X-Spam-Score: -0.0 (/)
X-Debbugs-Envelope-To: 38055-done
Cc: 38055-done <at> debbugs.gnu.org, Ivan Vilata i Balaguer <ivan@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)


--p7qwJlK53pWzbayA
Content-Type: text/plain; charset=utf-8
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

Some inline comments added. Patch pushed.

--=20
Efraim Flashner   <efraim@HIDDEN>   =D7=90=D7=A4=D7=A8=D7=99=D7=9D =
=D7=A4=D7=9C=D7=A9=D7=A0=D7=A8
GPG key =3D A28B F40C 3E55 1372 662D  14F7 41AA E7DC CA3D 8351
Confidentiality cannot be guaranteed on emails sent or received unencrypted

--p7qwJlK53pWzbayA
Content-Type: application/pgp-signature; name="signature.asc"

-----BEGIN PGP SIGNATURE-----

iQIzBAABCgAdFiEEoov0DD5VE3JmLRT3Qarn3Mo9g1EFAl3JKXUACgkQQarn3Mo9
g1G7sg/+KBFQJQYpGkmtmMhCWTUMKqRkERNgQgmwRJzn+yie1tXuc89cFMLwp9Mg
yjQT04EOMPCre+SvdczMGJeDav2ulqvNrLSLZN+SWDKxP6vx5F7iNK7JNmxGGj6J
KAe8cdivDzBxkL+wnqe+sSYtbV56EReHCAwnGsLXIe9/fJGBBUtA2PI1fbDQyxNB
UdxcMRePR195yr3H9+Vn16WqHeOqnRx1ifFlkLaolh6bsjtQEZQ4hfmaZgEaX9e3
Fvlto59vo3zakhU+IWvgbKxMqzLC3uWDW3qviU3uJhg6MhR7KZ7MPwmrcOQejKX0
OKa1mfKJc2oCHUBFHpz/pDMunXFkFZg2dXSUTr20YqiJLLf73l03s7UH4/Vr2ehH
zeIHjMQWVmEdl3iKA9+So6dtgwySuWuyzq2+/ezR9Y/wcH5+SfZnIycuADuwNrka
OdTYxdYAv207YAel/czmRojzi2mCKOCOssZTk0RNNt5N5IZnzfLTMVhuPRM0/Cxn
Xxhgc6Ikx0PXsD7Ql6WF0PPVGiAvcBJ+yZMKI6TlogqSXQiQvhsmKjpLDWZmrull
ayn6qPCj90wjuyDxE71agsOVfX9ZSZgSNVq1Sh7UUiAhLiEBVLax8vy5ul3k56yK
h7jM2kp0KMnFvC7Wh3r3dthITNJktfZ2OXb0otz/cv5RaJ57hYk=
=Zsjf
-----END PGP SIGNATURE-----

--p7qwJlK53pWzbayA--




Notification sent to Ivan Vilata i Balaguer <ivan@HIDDEN>:
bug acknowledged by developer. Full text available.
Reply sent to Efraim Flashner <efraim@HIDDEN>:
You have taken responsibility. Full text available.

Message received at 38055 <at> debbugs.gnu.org:


Received: (at 38055) by debbugs.gnu.org; 10 Nov 2019 14:14:55 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Nov 10 09:14:55 2019
Received: from localhost ([127.0.0.1]:50800 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1iTnzT-0000VO-Bt
	for submit <at> debbugs.gnu.org; Sun, 10 Nov 2019 09:14:55 -0500
Received: from eggs.gnu.org ([209.51.188.92]:60830)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <ludo@HIDDEN>) id 1iTnzO-0000V8-A1
 for 38055 <at> debbugs.gnu.org; Sun, 10 Nov 2019 09:14:53 -0500
Received: from fencepost.gnu.org ([2001:470:142:3::e]:54838)
 by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from <ludo@HIDDEN>)
 id 1iTnzI-0000on-Du; Sun, 10 Nov 2019 09:14:44 -0500
Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=38594 helo=ribbon)
 by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256)
 (Exim 4.82) (envelope-from <ludo@HIDDEN>)
 id 1iTnzI-0004UU-0s; Sun, 10 Nov 2019 09:14:44 -0500
From: =?utf-8?Q?Ludovic_Court=C3=A8s?= <ludo@HIDDEN>
To: Efraim Flashner <efraim@HIDDEN>
Subject: Re: none
References: <20191109182510.GA3954@E5400>
X-URL: http://www.fdn.fr/~lcourtes/
X-Revolutionary-Date: 20 Brumaire an 228 de la =?utf-8?Q?R=C3=A9volution?=
X-PGP-Key-ID: 0x090B11993D9AEBB5
X-PGP-Key: http://www.fdn.fr/~lcourtes/ludovic.asc
X-PGP-Fingerprint: 3CE4 6455 8A84 FDC6 9DB4  0CFB 090B 1199 3D9A EBB5
X-OS: x86_64-pc-linux-gnu
Date: Sun, 10 Nov 2019 15:14:42 +0100
In-Reply-To: <20191109182510.GA3954@E5400> (Efraim Flashner's message of "Sat, 
 9 Nov 2019 20:25:10 +0200")
Message-ID: <87k1873jjh.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 38055
Cc: 38055 <at> debbugs.gnu.org, Ivan Vilata i Balaguer <ivan@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

Hi,

Efraim Flashner <efraim@HIDDEN> skribis:

> From 2db156170a24fea36aced781faf96c839a3b7d15 Mon Sep 17 00:00:00 2001
> From: Efraim Flashner <efraim@HIDDEN>
> Date: Sat, 9 Nov 2019 20:19:11 +0200
> Subject: [PATCH] gnu: patchelf: Update to 0.10.
>
> * gnu/packages/elf.scm (patchelf): Update to 0.10.
> [source]: Remove patches.
> [arguments]: Remove patch/rework-for-arm phase. Add phase to modify
> tests for our modified GCC package.
> [native-inputs]: Add gcc:lib.
> * gnu/packages/patches/patchelf-page-size.patch,
> * gnu/packages/patches/patchelf-rework-for-arm.patch: Remove files.
> * gnu/local.mk (dist_patch_DATA): Remove them.

[...]

> +       (modify-phases %standard-phases
> +         (add-after 'unpack 'fix-tests
> +           ;; Our GCC code ensures that RUNPATH is never empty, it inclu=
des
> +           ;; at least glibc/lib and gcc:lib/lib.
> +           (lambda* (#:key inputs #:allow-other-keys)
> +             (substitute* "tests/no-rpath.sh"
> +               (("^if test.*") "")
> +               (("/xxxxxxxxxxxxxxx") (string-append (assoc-ref inputs "g=
cc:lib")
> +                                                    "/lib")))

Could you complement the above comment with something like: =E2=80=9CThus,
disable the test that checks for an empty RUNPATH.=E2=80=9D, or whatever is
appropriate?  That will clarify the intent because it=E2=80=99s not obvious=
 what
the substitution is doing if you don=E2=80=99t have the file at hand.  :-)

Otherwise LGTM, thanks for addressing this issue!

Ludo=E2=80=99.




Information forwarded to bug-guix@HIDDEN:
bug#38055; Package guix. Full text available.

Message received at 38055 <at> debbugs.gnu.org:


Received: (at 38055) by debbugs.gnu.org; 9 Nov 2019 18:26:04 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Nov 09 13:26:04 2019
Received: from localhost ([127.0.0.1]:50270 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1iTVQq-00026W-5g
	for submit <at> debbugs.gnu.org; Sat, 09 Nov 2019 13:26:04 -0500
Received: from flashner.co.il ([178.62.234.194]:43122)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <efraim@HIDDEN>) id 1iTVQh-000268-Uw
 for 38055 <at> debbugs.gnu.org; Sat, 09 Nov 2019 13:25:54 -0500
Received: from localhost (unknown [141.226.13.108])
 by flashner.co.il (Postfix) with ESMTPSA id 6BE2D402AA;
 Sat,  9 Nov 2019 18:25:41 +0000 (UTC)
Date: Sat, 9 Nov 2019 20:25:10 +0200
From: Efraim Flashner <efraim@HIDDEN>
To: Ludovic =?utf-8?Q?Court=C3=A8s?= <ludo@HIDDEN>
Message-ID: <20191109182510.GA3954@E5400>
MIME-Version: 1.0
Content-Type: multipart/signed; micalg=pgp-sha512;
 protocol="application/pgp-signature"; boundary="ftEhullJWpWg/VHq"
Content-Disposition: inline
User-Agent: Mutt/1.12.2 (2019-09-21)
X-Spam-Score: 2.0 (++)
X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org",
 has NOT identified this incoming email as spam.  The original
 message has been attached to this so you can view it or label
 similar future email.  If you have any questions, see
 the administrator of that system for details.
 Content preview: guix-patches@HIDDEN Bcc: Subject: Re: bug#38055: patchelf:
 Assertion failed when setting interpreter Reply-To: In-Reply-To:
 <87zhh7mmoo.fsf@HIDDEN>
 X-PGP-Key-ID: 0x41AAE7DCCA3D8351 X-PGP-Key: https: [...] 
 Content analysis details:   (2.0 points, 10.0 required)
 pts rule name              description
 ---- ---------------------- --------------------------------------------------
 -0.0 SPF_HELO_PASS          SPF: HELO matches SPF record
 -0.0 SPF_PASS               SPF: sender matches SPF record
 1.8 MISSING_SUBJECT        Missing Subject: header
 0.2 NO_SUBJECT             Extra score for no subject
X-Debbugs-Envelope-To: 38055
Cc: 38055 <at> debbugs.gnu.org, Ivan Vilata i Balaguer <ivan@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: 1.0 (+)


--ftEhullJWpWg/VHq
Content-Type: multipart/mixed; boundary="KsGdsel6WgEHnImy"
Content-Disposition: inline


--KsGdsel6WgEHnImy
Content-Type: text/plain; charset=utf-8
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

guix-patches@HIDDEN
Bcc:=20
Subject: Re: bug#38055: patchelf: Assertion failed when setting interpreter
Reply-To:=20
In-Reply-To: <87zhh7mmoo.fsf@HIDDEN>
X-PGP-Key-ID: 0x41AAE7DCCA3D8351
X-PGP-Key: https://flashner.co.il/~efraim/efraim_flashner.asc
X-PGP-Fingerprint: A28B F40C 3E55 1372 662D  14F7 41AA E7DC CA3D 8351
I put together a patch to bump patchelf to 0.10. 'guix refresh -l
patchelf' says there's 614 dependent packages, but 'git grep ,patchelf'
and 'git grep guix\ build\ rpath' it looks like there's julia and 613
haskell packages.


--=20
Efraim Flashner   <efraim@HIDDEN>   =D7=90=D7=A4=D7=A8=D7=99=D7=9D =
=D7=A4=D7=9C=D7=A9=D7=A0=D7=A8
GPG key =3D A28B F40C 3E55 1372 662D  14F7 41AA E7DC CA3D 8351
Confidentiality cannot be guaranteed on emails sent or received unencrypted

--KsGdsel6WgEHnImy
Content-Type: text/plain; charset=utf-8
Content-Disposition: attachment;
	filename="0001-gnu-patchelf-Update-to-0.10.patch"
Content-Transfer-Encoding: quoted-printable

=46rom 2db156170a24fea36aced781faf96c839a3b7d15 Mon Sep 17 00:00:00 2001
=46rom: Efraim Flashner <efraim@HIDDEN>
Date: Sat, 9 Nov 2019 20:19:11 +0200
Subject: [PATCH] gnu: patchelf: Update to 0.10.

* gnu/packages/elf.scm (patchelf): Update to 0.10.
[source]: Remove patches.
[arguments]: Remove patch/rework-for-arm phase. Add phase to modify
tests for our modified GCC package.
[native-inputs]: Add gcc:lib.
* gnu/packages/patches/patchelf-page-size.patch,
* gnu/packages/patches/patchelf-rework-for-arm.patch: Remove files.
* gnu/local.mk (dist_patch_DATA): Remove them.
---
 gnu/local.mk                                  |   2 -
 gnu/packages/elf.scm                          |  39 +-
 gnu/packages/patches/patchelf-page-size.patch |  70 ---
 .../patches/patchelf-rework-for-arm.patch     | 473 ------------------
 4 files changed, 17 insertions(+), 567 deletions(-)
 delete mode 100644 gnu/packages/patches/patchelf-page-size.patch
 delete mode 100644 gnu/packages/patches/patchelf-rework-for-arm.patch

diff --git a/gnu/local.mk b/gnu/local.mk
index 0f02c4b6be..1e6ab0dc66 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -1204,8 +1204,6 @@ dist_patch_DATA =3D						\
   %D%/packages/patches/p7zip-CVE-2016-9296.patch		\
   %D%/packages/patches/p7zip-CVE-2017-17969.patch		\
   %D%/packages/patches/p7zip-remove-unused-code.patch		\
-  %D%/packages/patches/patchelf-page-size.patch			\
-  %D%/packages/patches/patchelf-rework-for-arm.patch		\
   %D%/packages/patches/patchutils-test-perms.patch		\
   %D%/packages/patches/patch-hurd-path-max.patch		\
   %D%/packages/patches/pcre2-fix-jit_match-crash.patch		\
diff --git a/gnu/packages/elf.scm b/gnu/packages/elf.scm
index 4f365cf205..f494d1bc85 100644
--- a/gnu/packages/elf.scm
+++ b/gnu/packages/elf.scm
@@ -2,7 +2,7 @@
 ;;; Copyright =C2=A9 2013, 2014, 2015 Ludovic Court=C3=A8s <ludo@HIDDEN>
 ;;; Copyright =C2=A9 2014, 2015 Mark H Weaver <mhw@HIDDEN>
 ;;; Copyright =C2=A9 2015 Andreas Enge <andreas@HIDDEN>
-;;; Copyright =C2=A9 2017, 2018 Efraim Flashner <efraim@HIDDEN>
+;;; Copyright =C2=A9 2017, 2018, 2019 Efraim Flashner <efraim@HIDDEN=
il>
 ;;; Copyright =C2=A9 2017 Leo Famulari <leo@HIDDEN>
 ;;; Copyright =C2=A9 2018 Tobias Geerinckx-Rice <me@HIDDEN>
 ;;; Copyright =C2=A9 2018 Marius Bakke <mbakke@HIDDEN>
@@ -31,6 +31,7 @@
   #:use-module (gnu packages)
   #:use-module (gnu packages compression)
   #:use-module (gnu packages documentation)
+  #:use-module (gnu packages gcc)
   #:use-module (gnu packages m4)
   #:use-module (gnu packages pkg-config)
   #:use-module (gnu packages python)
@@ -198,7 +199,7 @@ static analysis of the ELF binaries at hand.")
 (define-public patchelf
   (package
     (name "patchelf")
-    (version "0.8")
+    (version "0.10")
     (source (origin
              (method url-fetch)
              (uri (string-append
@@ -207,28 +208,22 @@ static analysis of the ELF binaries at hand.")
                    "/patchelf-" version ".tar.bz2"))
              (sha256
               (base32
-               "1rqpg84wrd3fa16wa9vqdvasnc05yz49w207cz1l0wrl4k8q97y9"))
-             (patches (search-patches "patchelf-page-size.patch"))))
+               "1wzwvnlyf853hw9zgqq5522bvf8gqadk8icgqa41a5n7593csw7n"))))
     (build-system gnu-build-system)
-
-    ;; XXX: The upstream 'patchelf' doesn't support ARM.  The only availab=
le
-    ;;      patch makes significant changes to the algorithm, possibly
-    ;;      introducing bugs.  So, we apply the patch only on ARM systems.
-    (inputs
-     (if (target-arm32?)
-         `(("patch/rework-for-arm" ,(search-patch
-                                     "patchelf-rework-for-arm.patch")))
-         '()))
     (arguments
-     (if (target-arm32?)
-         `(#:phases
-           (modify-phases %standard-phases
-             (add-after 'unpack 'patch/rework-for-arm
-               (lambda* (#:key inputs #:allow-other-keys)
-                 (let ((patch-file (assoc-ref inputs "patch/rework-for-arm=
")))
-                   (invoke "patch" "--force" "-p1" "--input" patch-file)))=
)))
-         '()))
-
+     '(#:phases
+       (modify-phases %standard-phases
+         (add-after 'unpack 'fix-tests
+           ;; Our GCC code ensures that RUNPATH is never empty, it includes
+           ;; at least glibc/lib and gcc:lib/lib.
+           (lambda* (#:key inputs #:allow-other-keys)
+             (substitute* "tests/no-rpath.sh"
+               (("^if test.*") "")
+               (("/xxxxxxxxxxxxxxx") (string-append (assoc-ref inputs "gcc=
:lib")
+                                                    "/lib")))
+             #t)))))
+    (native-inputs
+     `(("gcc:lib" ,gcc "lib")))
     (home-page "https://nixos.org/patchelf.html")
     (synopsis "Modify the dynamic linker and RPATH of ELF executables")
     (description
diff --git a/gnu/packages/patches/patchelf-page-size.patch b/gnu/packages/p=
atches/patchelf-page-size.patch
deleted file mode 100644
index 1c14047512..0000000000
--- a/gnu/packages/patches/patchelf-page-size.patch
+++ /dev/null
@@ -1,70 +0,0 @@
-Improve the determination of pageSize in patchelf.cc.
-
-Patch by Mark H Weaver <mhw@HIDDEN>.
-
---- patchelf/src/patchelf.cc.orig	1969-12-31 19:00:01.000000000 -0500
-+++ patchelf/src/patchelf.cc	2014-02-16 20:15:06.283203125 -0500
-@@ -21,11 +21,19 @@
- using namespace std;
-=20
-=20
--#ifdef MIPSEL
--/* The lemote fuloong 2f kernel defconfig sets a page size of 16KB */
--const unsigned int pageSize =3D 4096*4;
--#else
-+/* Note that some platforms support multiple page sizes.  Therefore,
-+   it is not enough to query the current page size.  'pageSize' must
-+   be the maximum architectural page size for the platform, which is
-+   typically defined in the corresponding ABI document.
-+
-+   XXX FIXME: This won't work when we're cross-compiling.  */
-+
-+#if defined __MIPSEL__ || defined __MIPSEB__ || defined __aarch64__
-+const unsigned int pageSize =3D 65536;
-+#elif defined __x86_64__ || defined __i386__ || defined __arm__
- const unsigned int pageSize =3D 4096;
-+#else
-+# error maximum architectural page size unknown for this platform
- #endif
-=20
-=20
---- patchelf/tests/no-rpath.sh.orig	2014-01-14 08:17:47.000000000 -0500
-+++ patchelf/tests/no-rpath.sh	2015-01-06 18:31:53.418172797 -0500
-@@ -1,23 +1,23 @@
- #! /bin/sh -e
- SCRATCH=3Dscratch/$(basename $0 .sh)
-=20
--rm -rf ${SCRATCH}
--mkdir -p ${SCRATCH}
-+if [ "$(uname -m)" =3D i686 -a "$(uname -s)" =3D Linux ]; then
-+    rm -rf ${SCRATCH}
-+    mkdir -p ${SCRATCH}
-=20
--cp ${srcdir}/no-rpath ${SCRATCH}/
-+    cp ${srcdir}/no-rpath ${SCRATCH}/
-=20
--oldRPath=3D$(../src/patchelf --print-rpath ${SCRATCH}/no-rpath)
--if test -n "$oldRPath"; then exit 1; fi
--../src/patchelf \
--  --set-interpreter "$(../src/patchelf --print-interpreter ../src/patchel=
f)" \
--  --set-rpath /foo:/bar:/xxxxxxxxxxxxxxx ${SCRATCH}/no-rpath
-+    oldRPath=3D$(../src/patchelf --print-rpath ${SCRATCH}/no-rpath)
-+    if test -n "$oldRPath"; then exit 1; fi
-+    ../src/patchelf \
-+      --set-interpreter "$(../src/patchelf --print-interpreter ../src/pat=
chelf)" \
-+      --set-rpath /foo:/bar:/xxxxxxxxxxxxxxx ${SCRATCH}/no-rpath
-=20
--newRPath=3D$(../src/patchelf --print-rpath ${SCRATCH}/no-rpath)
--if ! echo "$newRPath" | grep -q '/foo:/bar'; then
--    echo "incomplete RPATH"
--    exit 1
--fi
-+    newRPath=3D$(../src/patchelf --print-rpath ${SCRATCH}/no-rpath)
-+    if ! echo "$newRPath" | grep -q '/foo:/bar'; then
-+        echo "incomplete RPATH"
-+        exit 1
-+    fi
-=20
--if [ "$(uname -m)" =3D i686 -a "$(uname -s)" =3D Linux ]; then
-     cd ${SCRATCH} && ./no-rpath
- fi
diff --git a/gnu/packages/patches/patchelf-rework-for-arm.patch b/gnu/packa=
ges/patches/patchelf-rework-for-arm.patch
deleted file mode 100644
index 6f4eb8f72b..0000000000
--- a/gnu/packages/patches/patchelf-rework-for-arm.patch
+++ /dev/null
@@ -1,473 +0,0 @@
-Rework the growing algorithm in patchelf to support ARM systems.
-See <https://github.com/NixOS/patchelf/issues/8>.
-This patch copied from:
-<https://github.com/sriemer/patchelf/commit/0a96239cea6b97b9a0fff80da576e5=
8ca2dfb2a2>
-
-From 0a96239cea6b97b9a0fff80da576e58ca2dfb2a2 Mon Sep 17 00:00:00 2001
-From: Sebastian Parschauer <s.parschauer@HIDDEN>
-Date: Sat, 28 Jun 2014 01:24:57 +0200
-Subject: [PATCH] Rework the growing algorithm
-
-On ARM systems there is no space in virtual memory for another LOAD
-area in front of the code LOAD area. So insert data to its end
-instead. At this location there should be enough space in virtual
-memory due to alignment. We can extend it until the end of the
-alignment but the file shift may be greater as it must be aligned
-to the page size. Do the same for the data LOAD area.
----
- src/patchelf.cc | 357 ++++++++++++++++++++++-----------------------------=
-----
- 1 file changed, 142 insertions(+), 215 deletions(-)
-
-diff --git a/src/patchelf.cc b/src/patchelf.cc
-index dcbfd38..4fce9e6 100644
---- a/src/patchelf.cc
-+++ b/src/patchelf.cc
-@@ -116,7 +116,11 @@ private:
-=20
-     void sortShdrs();
-=20
--    void shiftFile(unsigned int extraPages, Elf_Addr startPage);
-+    void shiftFileSingle(size_t fileShift, Elf_Off insertOff);
-+
-+    void shiftFile(size_t neededCode, size_t neededData,
-+                   Elf_Off codeOff[], Elf_Off dataOff[],
-+                   Elf_Addr *codePage, Elf_Addr *dataPage);
-=20
-     string getSectionName(const Elf_Shdr & shdr);
-=20
-@@ -130,13 +134,11 @@ private:
-         unsigned int size);
-=20
-     void writeReplacedSections(Elf_Off & curOff,
--        Elf_Addr startAddr, Elf_Off startOffset);
-+        Elf_Addr startAddr, Elf_Off startOffset, bool isData);
-=20
-     void rewriteHeaders(Elf_Addr phdrAddress);
-=20
--    void rewriteSectionsLibrary();
--
--    void rewriteSectionsExecutable();
-+    void rewriteSectionsBinary();
-=20
- public:
-=20
-@@ -391,46 +393,119 @@ static unsigned int roundUp(unsigned int n, unsigne=
d int m)
-=20
-=20
- template<ElfFileParams>
--void ElfFile<ElfFileParamNames>::shiftFile(unsigned int extraPages, Elf_A=
ddr startPage)
-+void ElfFile<ElfFileParamNames>::shiftFileSingle(size_t fileShift,
-+        Elf_Off insertOff)
- {
--    /* Move the entire contents of the file `extraPages' pages
--       further. */
-     unsigned int oldSize =3D fileSize;
--    unsigned int shift =3D extraPages * pageSize;
--    growFile(fileSize + extraPages * pageSize);
--    memmove(contents + extraPages * pageSize, contents, oldSize);
--    memset(contents + sizeof(Elf_Ehdr), 0, shift - sizeof(Elf_Ehdr));
-+
-+    /* Grow at the end */
-+    growFile(fileSize + fileShift);
-+
-+    /* move the data from the insertion point
-+       to the end and zero inserted space */
-+    memmove(contents + insertOff + fileShift,
-+            contents + insertOff, oldSize - insertOff);
-+    memset(contents + insertOff, 0, fileShift);
-=20
-     /* Adjust the ELF header. */
-     wri(hdr->e_phoff, sizeof(Elf_Ehdr));
--    wri(hdr->e_shoff, rdi(hdr->e_shoff) + shift);
-+    if (rdi(hdr->e_shoff) >=3D insertOff)
-+        wri(hdr->e_shoff, rdi(hdr->e_shoff) + fileShift);
-=20
-     /* Update the offsets in the section headers. */
--    for (int i =3D 1; i < rdi(hdr->e_shnum); ++i)
--        wri(shdrs[i].sh_offset, rdi(shdrs[i].sh_offset) + shift);
-+    for (int i =3D 1; i < rdi(hdr->e_shnum); ++i) {
-+        if (rdi(shdrs[i].sh_offset) >=3D insertOff)
-+            wri(shdrs[i].sh_offset, rdi(shdrs[i].sh_offset) + fileShift);
-+    }
-=20
-     /* Update the offsets in the program headers. */
-     for (int i =3D 0; i < rdi(hdr->e_phnum); ++i) {
--        wri(phdrs[i].p_offset, rdi(phdrs[i].p_offset) + shift);
--        if (rdi(phdrs[i].p_align) !=3D 0 &&
--            (rdi(phdrs[i].p_vaddr) - rdi(phdrs[i].p_offset)) % rdi(phdrs[=
i].p_align) !=3D 0) {
--            debug("changing alignment of program header %d from %d to %d\=
n", i,
--                rdi(phdrs[i].p_align), pageSize);
--            wri(phdrs[i].p_align, pageSize);
-+        if (rdi(phdrs[i].p_offset) >=3D insertOff)
-+            wri(phdrs[i].p_offset, rdi(phdrs[i].p_offset) + fileShift);
-+        /* Check for ELF load command alignment issue the same
-+           way as glibc/elf/dl-load.c does. This gives us the
-+           chance to run an interpreter explicitly. */
-+        if (rdi(phdrs[i].p_type) =3D=3D PT_LOAD && ((rdi(phdrs[i].p_vaddr=
) -
-+          rdi(phdrs[i].p_offset)) & (rdi(phdrs[i].p_align) - 1)) !=3D 0) {
-+             debug("changing alignment of program header %d from %d to %d=
\n",
-+                   i, rdi(phdrs[i].p_align), pageSize);
-+             wri(phdrs[i].p_align, pageSize);
-         }
-     }
-+}
-+
-+template<ElfFileParams>
-+void ElfFile<ElfFileParamNames>::shiftFile(size_t neededCode,
-+        size_t neededData, Elf_Off codeOff[], Elf_Off dataOff[],
-+        Elf_Addr *codePage, Elf_Addr *dataPage)
-+{
-+    /* Move some contents of the file further. The binary has one LOAD ar=
ea
-+     * for code and one for data. There is virtual memory space between
-+     * these which we can use due to alignment.
-+     */
-+    unsigned int memShift =3D neededCode;
-+    unsigned int fileShift =3D roundUp(neededCode, pageSize);
-+    unsigned int maxMemShift =3D 0;
-+
-+    if (neededCode > 0) {
-+        /* find the LOAD program header for code and extend it */
-+        for (int i =3D 0; i < rdi(hdr->e_phnum); ++i) {
-+            if (rdi(phdrs[i].p_type) =3D=3D PT_LOAD &&
-+              rdi(phdrs[i].p_flags) & PF_X) {
-+                codeOff[1] =3D rdi(phdrs[i].p_filesz);
-+                codeOff[0] =3D codeOff[1] + rdi(phdrs[i].p_offset);
-+                maxMemShift =3D rdi(phdrs[i].p_memsz) % rdi(phdrs[i].p_al=
ign);
-+                if (maxMemShift =3D=3D 0)
-+                    continue;
-+                maxMemShift =3D rdi(phdrs[i].p_align) - maxMemShift;
-+                if (maxMemShift =3D=3D 0 || memShift > maxMemShift)
-+                    continue;
-+                *codePage =3D rdi(phdrs[i].p_vaddr);
-+                wri(phdrs[i].p_filesz, rdi(phdrs[i].p_filesz) + memShift);
-+                wri(phdrs[i].p_memsz, rdi(phdrs[i].p_memsz) + memShift);
-+                break;
-+            }
-+        }
-+        debug("codeOff: %#lx, memShift: %d, maxMemShift: %d, fileShift: %=
d\n",
-+              codeOff[1], memShift, maxMemShift, fileShift);
-+        if (codeOff[1] =3D=3D 0 || maxMemShift =3D=3D 0)
-+            goto out;
-+
-+        shiftFileSingle(fileShift, codeOff[0]);
-+    }
-+
-+    /* +++ Do the same for the data LOAD area  +++ */
-+    memShift =3D neededData;
-+    fileShift =3D roundUp(neededData, pageSize);
-+    maxMemShift =3D 0;
-+    if (neededData > 0) {
-+        /* find the LOAD program header for data and extend it */
-+        for (int i =3D 0; i < rdi(hdr->e_phnum); ++i) {
-+            if (rdi(phdrs[i].p_type) =3D=3D PT_LOAD &&
-+              rdi(phdrs[i].p_flags) & PF_W) {
-+                dataOff[1] =3D rdi(phdrs[i].p_filesz);
-+                dataOff[0] =3D dataOff[1] + rdi(phdrs[i].p_offset);
-+                maxMemShift =3D rdi(phdrs[i].p_memsz) % rdi(phdrs[i].p_al=
ign);
-+                if (maxMemShift =3D=3D 0)
-+                    continue;
-+                maxMemShift =3D rdi(phdrs[i].p_align) - maxMemShift;
-+                if (maxMemShift =3D=3D 0 || memShift > maxMemShift)
-+                    continue;
-+                *dataPage =3D rdi(phdrs[i].p_vaddr);
-+                wri(phdrs[i].p_filesz, rdi(phdrs[i].p_filesz) + memShift);
-+                wri(phdrs[i].p_memsz, rdi(phdrs[i].p_memsz) + memShift);
-+                break;
-+            }
-+        }
-+        debug("dataOff: %#lx, memShift: %d, maxMemShift: %d, fileShift: %=
d\n",
-+              dataOff[1], memShift, maxMemShift, fileShift);
-+        if (dataOff[1] =3D=3D 0 || maxMemShift =3D=3D 0)
-+            goto out;
-=20
--    /* Add a segment that maps the new program/section headers and
--       PT_INTERP segment into memory.  Otherwise glibc will choke. */
--    phdrs.resize(rdi(hdr->e_phnum) + 1);
--    wri(hdr->e_phnum, rdi(hdr->e_phnum) + 1);
--    Elf_Phdr & phdr =3D phdrs[rdi(hdr->e_phnum) - 1];
--    wri(phdr.p_type, PT_LOAD);
--    wri(phdr.p_offset, 0);
--    wri(phdr.p_vaddr, wri(phdr.p_paddr, startPage));
--    wri(phdr.p_filesz, wri(phdr.p_memsz, shift));
--    wri(phdr.p_flags, PF_R | PF_W);
--    wri(phdr.p_align, pageSize);
-+        shiftFileSingle(fileShift, dataOff[0]);
-+    }
-+out:
-+    return;
- }
-=20
-=20
-@@ -491,7 +566,7 @@ string & ElfFile<ElfFileParamNames>::replaceSection(co=
nst SectionName & sectionN
-=20
- template<ElfFileParams>
- void ElfFile<ElfFileParamNames>::writeReplacedSections(Elf_Off & curOff,
--    Elf_Addr startAddr, Elf_Off startOffset)
-+    Elf_Addr startAddr, Elf_Off startOffset, bool isData =3D false)
- {
-     /* Overwrite the old section contents with 'X's.  Do this
-        *before* writing the new section contents (below) to prevent
-@@ -501,6 +576,9 @@ void ElfFile<ElfFileParamNames>::writeReplacedSections=
(Elf_Off & curOff,
-     {
-         string sectionName =3D i->first;
-         Elf_Shdr & shdr =3D findSection(sectionName);
-+        if ((!isData && rdi(shdr.sh_flags) & SHF_WRITE) ||
-+         (isData && ~(rdi(shdr.sh_flags)) & SHF_WRITE))
-+            continue;
-         memset(contents + rdi(shdr.sh_offset), 'X', rdi(shdr.sh_size));
-     }
-=20
-@@ -509,6 +587,9 @@ void ElfFile<ElfFileParamNames>::writeReplacedSections=
(Elf_Off & curOff,
-     {
-         string sectionName =3D i->first;
-         Elf_Shdr & shdr =3D findSection(sectionName);
-+        if ((!isData && rdi(shdr.sh_flags) & SHF_WRITE) ||
-+         (isData && ~(rdi(shdr.sh_flags)) & SHF_WRITE))
-+            continue;
-         debug("rewriting section `%s' from offset 0x%x (size %d) to offse=
t 0x%x (size %d)\n",
-             sectionName.c_str(), rdi(shdr.sh_offset), rdi(shdr.sh_size), =
curOff, i->second.size());
-=20
-@@ -546,201 +627,47 @@ void ElfFile<ElfFileParamNames>::writeReplacedSecti=
ons(Elf_Off & curOff,
-         curOff +=3D roundUp(i->second.size(), sectionAlignment);
-     }
-=20
--    replacedSections.clear();
-+    if (isData)
-+        replacedSections.clear();
- }
-=20
-=20
- template<ElfFileParams>
--void ElfFile<ElfFileParamNames>::rewriteSectionsLibrary()
-+void ElfFile<ElfFileParamNames>::rewriteSectionsBinary()
- {
--    /* For dynamic libraries, we just place the replacement sections
--       at the end of the file.  They're mapped into memory by a
--       PT_LOAD segment located directly after the last virtual address
--       page of other segments. */
--    Elf_Addr startPage =3D 0;
--    for (unsigned int i =3D 0; i < phdrs.size(); ++i) {
--        Elf_Addr thisPage =3D roundUp(rdi(phdrs[i].p_vaddr) + rdi(phdrs[i=
].p_memsz), pageSize);
--        if (thisPage > startPage) startPage =3D thisPage;
--    }
--
--    debug("last page is 0x%llx\n", (unsigned long long) startPage);
-+    Elf_Off codeOff[2] =3D {0}, dataOff[2] =3D {0};
-+    Elf_Addr codePage =3D 0, dataPage =3D 0;
-+    size_t neededCode =3D 0, neededData =3D 0, oldCode =3D 0, oldData =3D=
 0;
-+    Elf_Shdr shdr =3D findSection(".text");
-+    Elf_Addr firstPage =3D rdi(shdr.sh_addr) - rdi(shdr.sh_offset);
-=20
-+    debug("first page is 0x%llx\n", (unsigned long long) firstPage);
-=20
--    /* Compute the total space needed for the replaced sections and
--       the program headers. */
--    off_t neededSpace =3D (phdrs.size() + 1) * sizeof(Elf_Phdr);
-+    /* Compute the total space needed for the replaced sections */
-     for (ReplacedSections::iterator i =3D replacedSections.begin();
--         i !=3D replacedSections.end(); ++i)
--        neededSpace +=3D roundUp(i->second.size(), sectionAlignment);
--    debug("needed space is %d\n", neededSpace);
--
--
--    size_t startOffset =3D roundUp(fileSize, pageSize);
--
--    growFile(startOffset + neededSpace);
--
--
--    /* Even though this file is of type ET_DYN, it could actually be
--       an executable.  For instance, Gold produces executables marked
--       ET_DYN.  In that case we can still hit the kernel bug that
--       necessitated rewriteSectionsExecutable().  However, such
--       executables also tend to start at virtual address 0, so
--       rewriteSectionsExecutable() won't work because it doesn't have
--       any virtual address space to grow downwards into.  As a
--       workaround, make sure that the virtual address of our new
--       PT_LOAD segment relative to the first PT_LOAD segment is equal
--       to its offset; otherwise we hit the kernel bug.  This may
--       require creating a hole in the executable.  The bigger the size
--       of the uninitialised data segment, the bigger the hole. */
--    if (isExecutable) {
--        if (startOffset >=3D startPage) {
--            debug("shifting new PT_LOAD segment by %d bytes to work aroun=
d a Linux kernel bug\n", startOffset - startPage);
--        } else {
--            size_t hole =3D startPage - startOffset;
--            /* Print a warning, because the hole could be very big. */
--            fprintf(stderr, "warning: working around a Linux kernel bug b=
y creating a hole of %zu bytes in =E2=80=98%s=E2=80=99\n", hole, fileName.c=
_str());
--            assert(hole % pageSize =3D=3D 0);
--            /* !!! We could create an actual hole in the file here,
--               but it's probably not worth the effort. */
--            growFile(fileSize + hole);
--            startOffset +=3D hole;
--        }
--        startPage =3D startOffset;
--    }
--
--
--    /* Add a segment that maps the replaced sections and program
--       headers into memory. */
--    phdrs.resize(rdi(hdr->e_phnum) + 1);
--    wri(hdr->e_phnum, rdi(hdr->e_phnum) + 1);
--    Elf_Phdr & phdr =3D phdrs[rdi(hdr->e_phnum) - 1];
--    wri(phdr.p_type, PT_LOAD);
--    wri(phdr.p_offset, startOffset);
--    wri(phdr.p_vaddr, wri(phdr.p_paddr, startPage));
--    wri(phdr.p_filesz, wri(phdr.p_memsz, neededSpace));
--    wri(phdr.p_flags, PF_R | PF_W);
--    wri(phdr.p_align, pageSize);
--
--
--    /* Write out the replaced sections. */
--    Elf_Off curOff =3D startOffset + phdrs.size() * sizeof(Elf_Phdr);
--    writeReplacedSections(curOff, startPage, startOffset);
--    assert((off_t) curOff =3D=3D startOffset + neededSpace);
--
--
--    /* Move the program header to the start of the new area. */
--    wri(hdr->e_phoff, startOffset);
--
--    rewriteHeaders(startPage);
--}
--
--
--template<ElfFileParams>
--void ElfFile<ElfFileParamNames>::rewriteSectionsExecutable()
--{
--    /* Sort the sections by offset, otherwise we won't correctly find
--       all the sections before the last replaced section. */
--    sortShdrs();
--
--
--    /* What is the index of the last replaced section? */
--    unsigned int lastReplaced =3D 0;
--    for (unsigned int i =3D 1; i < rdi(hdr->e_shnum); ++i) {
--        string sectionName =3D getSectionName(shdrs[i]);
--        if (replacedSections.find(sectionName) !=3D replacedSections.end(=
)) {
--            debug("using replaced section `%s'\n", sectionName.c_str());
--            lastReplaced =3D i;
--        }
--    }
--
--    assert(lastReplaced !=3D 0);
--
--    debug("last replaced is %d\n", lastReplaced);
--
--    /* Try to replace all sections before that, as far as possible.
--       Stop when we reach an irreplacable section (such as one of type
--       SHT_PROGBITS).  These cannot be moved in virtual address space
--       since that would invalidate absolute references to them. */
--    assert(lastReplaced + 1 < shdrs.size()); /* !!! I'm lazy. */
--    size_t startOffset =3D rdi(shdrs[lastReplaced + 1].sh_offset);
--    Elf_Addr startAddr =3D rdi(shdrs[lastReplaced + 1].sh_addr);
--    string prevSection;
--    for (unsigned int i =3D 1; i <=3D lastReplaced; ++i) {
--        Elf_Shdr & shdr(shdrs[i]);
--        string sectionName =3D getSectionName(shdr);
--        debug("looking at section `%s'\n", sectionName.c_str());
--        /* !!! Why do we stop after a .dynstr section? I can't
--           remember! */
--        if ((rdi(shdr.sh_type) =3D=3D SHT_PROGBITS && sectionName !=3D ".=
interp")
--            || prevSection =3D=3D ".dynstr")
--        {
--            startOffset =3D rdi(shdr.sh_offset);
--            startAddr =3D rdi(shdr.sh_addr);
--            lastReplaced =3D i - 1;
--            break;
-+         i !=3D replacedSections.end(); ++i) {
-+        shdr =3D findSection(i->first);
-+        if (rdi(shdr.sh_flags) & SHF_WRITE) {
-+            oldData +=3D rdi(shdr.sh_size);
-+            neededData +=3D roundUp(i->second.size(), sectionAlignment);
-         } else {
--            if (replacedSections.find(sectionName) =3D=3D replacedSection=
s.end()) {
--                debug("replacing section `%s' which is in the way\n", sec=
tionName.c_str());
--                replaceSection(sectionName, rdi(shdr.sh_size));
--            }
-+            oldCode +=3D rdi(shdr.sh_size);
-+            neededCode +=3D roundUp(i->second.size(), sectionAlignment);
-         }
--        prevSection =3D sectionName;
-     }
-=20
--    debug("first reserved offset/addr is 0x%x/0x%llx\n",
--        startOffset, (unsigned long long) startAddr);
--
--    assert(startAddr % pageSize =3D=3D startOffset % pageSize);
--    Elf_Addr firstPage =3D startAddr - startOffset;
--    debug("first page is 0x%llx\n", (unsigned long long) firstPage);
--
--    /* Right now we assume that the section headers are somewhere near
--       the end, which appears to be the case most of the time.
--       Therefore they're not accidentally overwritten by the replaced
--       sections. !!!  Fix this. */
--    assert((off_t) rdi(hdr->e_shoff) >=3D startOffset);
--
--
--    /* Compute the total space needed for the replaced sections, the
--       ELF header, and the program headers. */
--    size_t neededSpace =3D sizeof(Elf_Ehdr) + phdrs.size() * sizeof(Elf_P=
hdr);
--    for (ReplacedSections::iterator i =3D replacedSections.begin();
--         i !=3D replacedSections.end(); ++i)
--        neededSpace +=3D roundUp(i->second.size(), sectionAlignment);
--
--    debug("needed space is %d\n", neededSpace);
--
--    /* If we need more space at the start of the file, then grow the
--       file by the minimum number of pages and adjust internal
--       offsets. */
--    if (neededSpace > startOffset) {
--
--        /* We also need an additional program header, so adjust for that.=
 */
--        neededSpace +=3D sizeof(Elf_Phdr);
--        debug("needed space is %d\n", neededSpace);
--
--        unsigned int neededPages =3D roundUp(neededSpace - startOffset, p=
ageSize) / pageSize;
--        debug("needed pages is %d\n", neededPages);
--        if (neededPages * pageSize > firstPage)
--            error("virtual address space underrun!");
--
--        firstPage -=3D neededPages * pageSize;
--        startOffset +=3D neededPages * pageSize;
--
--        shiftFile(neededPages, firstPage);
--    }
--
--
--    /* Clear out the free space. */
--    Elf_Off curOff =3D sizeof(Elf_Ehdr) + phdrs.size() * sizeof(Elf_Phdr);
--    debug("clearing first %d bytes\n", startOffset - curOff);
--    memset(contents + curOff, 0, startOffset - curOff);
-+    debug("needed space is C: %d, D: %d\n", neededCode, neededData);
-=20
-+    /* If we need more space within the file, then grow the
-+       file and adjust internal offsets. */
-+    shiftFile(neededCode, neededData, codeOff, dataOff, &codePage,
-+              &dataPage);
-+    assert(codeOff[0] > 0);
-=20
-     /* Write out the replaced sections. */
--    writeReplacedSections(curOff, firstPage, 0);
--    assert((off_t) curOff =3D=3D neededSpace);
--
-+    debug("codePage: %#lx, dataPage: %#lx\n", codePage, dataPage);
-+    writeReplacedSections(codeOff[0], codePage + codeOff[1], codeOff[0]);
-+    writeReplacedSections(dataOff[0], dataPage + dataOff[1], dataOff[0], =
true);
-=20
-     rewriteHeaders(firstPage + rdi(hdr->e_phoff));
- }
-@@ -758,10 +685,10 @@ void ElfFile<ElfFileParamNames>::rewriteSections()
-=20
-     if (rdi(hdr->e_type) =3D=3D ET_DYN) {
-         debug("this is a dynamic library\n");
--        rewriteSectionsLibrary();
-+        rewriteSectionsBinary();
-     } else if (rdi(hdr->e_type) =3D=3D ET_EXEC) {
-         debug("this is an executable\n");
--        rewriteSectionsExecutable();
-+        rewriteSectionsBinary();
-     } else error("unknown ELF type");
- }
-=20
---=20
-2.1.2
-
--=20
2.24.0


--KsGdsel6WgEHnImy--

--ftEhullJWpWg/VHq
Content-Type: application/pgp-signature; name="signature.asc"

-----BEGIN PGP SIGNATURE-----

iQIzBAABCgAdFiEEoov0DD5VE3JmLRT3Qarn3Mo9g1EFAl3HBIYACgkQQarn3Mo9
g1FAdQ/9FfEXXZeUzthfZinUEVdX77z+XUPlcWXkwnmdfJZO0tJVdUqfS58edp3r
7Ttxh/ApYJ2sQX30BZINvD6kIvrLVFEqfVjUHjhk23QoNJo9qO6FPXJ2yaP+Ama0
lefX52cw1x6ibJFDiZQvRgsQakJz0JTu96777HZvIG50ZsJ8E7hvirIGl2ut881L
BYN2Q1JBARttfRzxkSm9ZBMOvQOjqPgmSTGHnrRB7Jh5x5nHMXQrcVOcysKKctDy
9VhLWzQhR6Rbnv347aB9d+Q2xyZeVJDH/CE2fv9JRsW3M43IqhPipxCIy+dxa/yJ
AOBGDWubP7GqREPo/VwjEzzutW1bRqwuyaequX/T5rcnYM1rUoA5/YPc4iL09XPf
T8iWKX8OAqM9Ypr0XmmLwZudzc6aAGtvPA5g8i2/nHUxszkig/Cz4jjVsTHlQZKC
JAKAvRqpmd84xht450HCmA+FmSyiDeENqTforiSOJW9eQRdTcoE0RiNL7VJNTI2m
1fAb8m3MEdGdSHte0L999TT5EG3ITebQsM/AjpJGb95kfWXT0iTWx0Y9EazKKfuk
t7SVpxZ2v+hvgjeBtQ40qhvqpi4kzInUVIPtKgOS1h194M2AQpsqx5UpOP99beg8
jOqar6t78dP9/URIoVs3jf9WWbA/QgTZCZ2jLMVjUGkml+pVglk=
=GFta
-----END PGP SIGNATURE-----

--ftEhullJWpWg/VHq--




Information forwarded to bug-guix@HIDDEN:
bug#38055; Package guix. Full text available.

Message received at 38055 <at> debbugs.gnu.org:


Received: (at 38055) by debbugs.gnu.org; 7 Nov 2019 20:55:19 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Nov 07 15:55:19 2019
Received: from localhost ([127.0.0.1]:43982 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1iSooJ-0000XR-02
	for submit <at> debbugs.gnu.org; Thu, 07 Nov 2019 15:55:19 -0500
Received: from eggs.gnu.org ([209.51.188.92]:46141)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <ludo@HIDDEN>) id 1iSooH-0000XC-9y
 for 38055 <at> debbugs.gnu.org; Thu, 07 Nov 2019 15:55:17 -0500
Received: from fencepost.gnu.org ([2001:470:142:3::e]:51186)
 by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from <ludo@HIDDEN>)
 id 1iSooB-0004RX-BE; Thu, 07 Nov 2019 15:55:11 -0500
Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=38828 helo=ribbon)
 by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256)
 (Exim 4.82) (envelope-from <ludo@HIDDEN>)
 id 1iSoo5-0001fr-VH; Thu, 07 Nov 2019 15:55:07 -0500
From: =?utf-8?Q?Ludovic_Court=C3=A8s?= <ludo@HIDDEN>
To: Ivan Vilata i Balaguer <ivan@HIDDEN>
Subject: Re: bug#38055: patchelf: Assertion failed when setting interpreter
References: <20191104045614.GI17621@HIDDEN>
 <87muda1kfs.fsf@HIDDEN> <20191105161822.GG14453@E5400>
 <20191106214221.GL17621@HIDDEN>
X-URL: http://www.fdn.fr/~lcourtes/
X-Revolutionary-Date: 17 Brumaire an 228 de la =?utf-8?Q?R=C3=A9volution?=
X-PGP-Key-ID: 0x090B11993D9AEBB5
X-PGP-Key: http://www.fdn.fr/~lcourtes/ludovic.asc
X-PGP-Fingerprint: 3CE4 6455 8A84 FDC6 9DB4  0CFB 090B 1199 3D9A EBB5
X-OS: x86_64-pc-linux-gnu
Date: Thu, 07 Nov 2019 21:55:03 +0100
In-Reply-To: <20191106214221.GL17621@HIDDEN> (Ivan Vilata
 i. Balaguer's message of "Wed, 6 Nov 2019 16:42:21 -0500")
Message-ID: <87zhh7mmoo.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 38055
Cc: Efraim Flashner <efraim@HIDDEN>, 38055 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

Bona nit!

Ivan Vilata i Balaguer <ivan@HIDDEN> skribis:

> Yeah, as I mentioned in the original mail that particular problem does in=
deed
> seem to be fixed in 0.10.  However when I try to build that source with `=
guix
> build patchelf --with-source=3D=E2=80=A6`, tests fail.
>
> If I run `guix environment -C --pure patchelf` then unpack and build the
> source, the only test that actually fails is `no-rpath.sh`.  If I run `sh=
 -x
> no-rpath.sh` I get this:
>
> ```
> ++ basename no-rpath.sh .sh
> + SCRATCH=3Dscratch/no-rpath
> + rm -rf scratch/no-rpath
> + mkdir -p scratch/no-rpath
> + cp no-rpath scratch/no-rpath/
> ++ ../src/patchelf --print-rpath scratch/no-rpath/no-rpath
> + oldRPath=3D/gnu/store/ahqgl4h89xqj695lgqvsaf6zh2nhy4pj-glibc-2.29/lib:/=
gnu/store/2plcy91lypnbbysb18ymnhaw3zwk8pg1-gcc-7.4.0-lib/lib:/gnu/store/2pl=
cy91lypnbbysb18ymnhaw3zwk8pg1-gcc-7.4.0-lib/lib/gcc/x86_64-unknown-linux-gn=
u/7.4.0/../../..:/gnu/store/dcrwf5irwh39knld1wim1qkny659af9g-profile/lib
> + test -n /gnu/store/ahqgl4h89xqj695lgqvsaf6zh2nhy4pj-glibc-2.29/lib:/gnu=
/store/2plcy91lypnbbysb18ymnhaw3zwk8pg1-gcc-7.4.0-lib/lib:/gnu/store/2plcy9=
1lypnbbysb18ymnhaw3zwk8pg1-gcc-7.4.0-lib/lib/gcc/x86_64-unknown-linux-gnu/7=
.4.0/../../..:/gnu/store/dcrwf5irwh39knld1wim1qkny659af9g-profile/lib
> + exit 1
> ```
>
> To succeed, the output of `=E2=80=A6/patchelf --print-rpath =E2=80=A6/no-=
rpath`
> (i.e. `oldRPath`) should be empty.  I'm not that familiar with Guix's GNU
> build system, but is that at all possible under Guix?  I mean, maybe the =
test
> is pointless or must be altered in some Guix-specific way for the `no-rpa=
th`
> binary not to have an rpath.

Guix=E2=80=99 =E2=80=98gcc=E2=80=99 automatically adds RUNPATH entries to g=
libc/lib and
gcc:lib/lib:

--8<---------------cut here---------------start------------->8---
$ gcc -dumpspecs |grep -e -rpath
%{!mandroid|tno-android-ld:-L/gnu/store/ahqgl4h89xqj695lgqvsaf6zh2nhy4pj-gl=
ibc-2.29/lib %{!static:-rpath=3D/gnu/store/ahqgl4h89xqj695lgqvsaf6zh2nhy4pj=
-glibc-2.29/lib %{!static-libgcc:-rpath=3D/gnu/store/347y0zr1a9s2f5pkcncgi3=
gd0r33qq81-gcc-9.2.0-lib/lib -lgcc_s}} %{pthread:-lpthread} %{shared:-lc}  =
  %{!shared:%{profile:-lc_p}%{!profile:-lc}};:%{shared:-lc}    %{!shared:%{=
profile:-lc_p}%{!profile:-lc}} %{!static: -ldl}}
--8<---------------cut here---------------end--------------->8---

The code that modifies GCC to do that is in (gnu packages gcc).

Thus, RUNPATH is never empty, and the test above is bound to fail.

Two possibilities: change the test to ensure that =E2=80=98--print-rpath=E2=
=80=99
returns precisely libc/lib:gcc/lib, or, if that turns out to be tricky,
skip the test (in both cases, add a comment linking to this discussion
for future reference.)

How does that sound?

Thank you!

Ludo=E2=80=99.




Information forwarded to bug-guix@HIDDEN:
bug#38055; Package guix. Full text available.

Message received at 38055 <at> debbugs.gnu.org:


Received: (at 38055) by debbugs.gnu.org; 6 Nov 2019 21:43:21 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Nov 06 16:43:21 2019
Received: from localhost ([127.0.0.1]:41336 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1iST5F-0007MH-0P
	for submit <at> debbugs.gnu.org; Wed, 06 Nov 2019 16:43:21 -0500
Received: from lev.selidor.net ([66.246.138.156]:47471)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <ivan@HIDDEN>) id 1iST5B-0007M8-LJ
 for 38055 <at> debbugs.gnu.org; Wed, 06 Nov 2019 16:43:20 -0500
Received: from sax.terramar.selidor.net (unknown
 [IPv6:2600:3c03:e001:114e:a0bd:c575:f2ee:58bf])
 by lev.selidor.net (Postfix) with ESMTP id 05920C82E;
 Wed,  6 Nov 2019 21:43:17 +0000 (UTC)
Received: by sax.terramar.selidor.net (Postfix, from userid 1000)
 id B0A4B9A36DE; Wed,  6 Nov 2019 16:42:21 -0500 (EST)
Date: Wed, 6 Nov 2019 16:42:21 -0500
From: Ivan Vilata i Balaguer <ivan@HIDDEN>
To: Efraim Flashner <efraim@HIDDEN>
Subject: Re: bug#38055: patchelf: Assertion failed when setting interpreter
Message-ID: <20191106214221.GL17621@HIDDEN>
References: <20191104045614.GI17621@HIDDEN>
 <87muda1kfs.fsf@HIDDEN> <20191105161822.GG14453@E5400>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Disposition: inline
Content-Transfer-Encoding: 8bit
In-Reply-To: <20191105161822.GG14453@E5400>
User-Agent: Mutt/1.12.2 (2019-09-21)
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 38055
Cc: Ludovic =?iso-8859-1?Q?Court=E8s?= <ludo@HIDDEN>, 38055 <at> debbugs.gnu.org,
 Ivan Vilata i Balaguer <ivan@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Efraim Flashner (2019-11-05 18:18:22 +0200) wrote:

> On Tue, Nov 05, 2019 at 03:12:23PM +0100, Ludovic Courtès wrote:
> > 
> > Ivan Vilata i Balaguer <ivan@HIDDEN> skribis:
> > 
> > > Hi, I'm using patchelf 0.8 from Guix commit 7f81cce3 on Debian Sid.
> > > When trying to patch the `go` binary from
> > > <https://dl.google.com/go/go1.12.3.linux-amd64.tar.gz>, I get the
> > > following error:
> > >
> > >     ivan@sax /tmp/tmps2Cv6w [env]$ patchelf --print-interpreter $SHELL
> > >     /gnu/store/ahqgl4h89xqj695lgqvsaf6zh2nhy4pj-glibc-2.29/lib/ld-linux-x86-64.so.2
> > >     ivan@sax /tmp/tmps2Cv6w [env]$ patchelf --set-interpreter $(patchelf --print-interpreter $SHELL) /tmp/tmps2Cv6w/golang/bin/go
> > >     patchelf: patchelf.cc:701: void ElfFile<Elf_Ehdr, Elf_Phdr, Elf_Shdr, Elf_Addr, Elf_Off, Elf_Dyn, Elf_Sym>::rewriteSectionsExecutable() \
> > >      [with Elf_Ehdr = Elf64_Ehdr; Elf_Phdr = Elf64_Phdr; Elf_Shdr = Elf64_Shdr; Elf_Addr = long unsigned int; Elf_Off = long unsigned int; \
> > >      Elf_Dyn = Elf64_Dyn; Elf_Sym = Elf64_Sym]: Assertion `(off_t) rdi(hdr->e_shoff) >= startOffset' failed.
> > >     Aborted
> > 
> > I think it’s a bug you should report upstream to the PatchELF
> > maintainers; it’s probably not Guix-specific.
> 
> On the other hand, if I were the patchelf maintainers, I'd suggest
> upgrading our package from 0.8 to a newer version.

Yeah, as I mentioned in the original mail that particular problem does indeed
seem to be fixed in 0.10.  However when I try to build that source with `guix
build patchelf --with-source=…`, tests fail.

If I run `guix environment -C --pure patchelf` then unpack and build the
source, the only test that actually fails is `no-rpath.sh`.  If I run `sh -x
no-rpath.sh` I get this:

```
++ basename no-rpath.sh .sh
+ SCRATCH=scratch/no-rpath
+ rm -rf scratch/no-rpath
+ mkdir -p scratch/no-rpath
+ cp no-rpath scratch/no-rpath/
++ ../src/patchelf --print-rpath scratch/no-rpath/no-rpath
+ oldRPath=/gnu/store/ahqgl4h89xqj695lgqvsaf6zh2nhy4pj-glibc-2.29/lib:/gnu/store/2plcy91lypnbbysb18ymnhaw3zwk8pg1-gcc-7.4.0-lib/lib:/gnu/store/2plcy91lypnbbysb18ymnhaw3zwk8pg1-gcc-7.4.0-lib/lib/gcc/x86_64-unknown-linux-gnu/7.4.0/../../..:/gnu/store/dcrwf5irwh39knld1wim1qkny659af9g-profile/lib
+ test -n /gnu/store/ahqgl4h89xqj695lgqvsaf6zh2nhy4pj-glibc-2.29/lib:/gnu/store/2plcy91lypnbbysb18ymnhaw3zwk8pg1-gcc-7.4.0-lib/lib:/gnu/store/2plcy91lypnbbysb18ymnhaw3zwk8pg1-gcc-7.4.0-lib/lib/gcc/x86_64-unknown-linux-gnu/7.4.0/../../..:/gnu/store/dcrwf5irwh39knld1wim1qkny659af9g-profile/lib
+ exit 1
```

To succeed, the output of `…/patchelf --print-rpath …/no-rpath`
(i.e. `oldRPath`) should be empty.  I'm not that familiar with Guix's GNU
build system, but is that at all possible under Guix?  I mean, maybe the test
is pointless or must be altered in some Guix-specific way for the `no-rpath`
binary not to have an rpath.

Cheers,

-- 
Ivan Vilata i Balaguer -- https://elvil.net/




Information forwarded to bug-guix@HIDDEN:
bug#38055; Package guix. Full text available.

Message received at 38055 <at> debbugs.gnu.org:


Received: (at 38055) by debbugs.gnu.org; 5 Nov 2019 16:18:31 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Nov 05 11:18:31 2019
Received: from localhost ([127.0.0.1]:38995 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1iS1XK-0001z2-MU
	for submit <at> debbugs.gnu.org; Tue, 05 Nov 2019 11:18:30 -0500
Received: from flashner.co.il ([178.62.234.194]:55648)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <efraim@HIDDEN>) id 1iS1XJ-0001ym-0k
 for 38055 <at> debbugs.gnu.org; Tue, 05 Nov 2019 11:18:29 -0500
Received: from localhost (unknown [141.226.13.108])
 by flashner.co.il (Postfix) with ESMTPSA id 300DD40213;
 Tue,  5 Nov 2019 16:18:23 +0000 (UTC)
Date: Tue, 5 Nov 2019 18:18:22 +0200
From: Efraim Flashner <efraim@HIDDEN>
To: Ludovic =?utf-8?Q?Court=C3=A8s?= <ludo@HIDDEN>
Subject: Re: bug#38055: patchelf: Assertion failed when setting interpreter
Message-ID: <20191105161822.GG14453@E5400>
References: <20191104045614.GI17621@HIDDEN>
 <87muda1kfs.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: multipart/signed; micalg=pgp-sha512;
 protocol="application/pgp-signature"; boundary="FLPM4o+7JoHGki3m"
Content-Disposition: inline
In-Reply-To: <87muda1kfs.fsf@HIDDEN>
X-PGP-Key-ID: 0x41AAE7DCCA3D8351
X-PGP-Key: https://flashner.co.il/~efraim/efraim_flashner.asc
X-PGP-Fingerprint: A28B F40C 3E55 1372 662D  14F7 41AA E7DC CA3D 8351
User-Agent: Mutt/1.12.2 (2019-09-21)
X-Spam-Score: -0.0 (/)
X-Debbugs-Envelope-To: 38055
Cc: 38055 <at> debbugs.gnu.org, Ivan Vilata i Balaguer <ivan@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)


--FLPM4o+7JoHGki3m
Content-Type: text/plain; charset=utf-8
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Tue, Nov 05, 2019 at 03:12:23PM +0100, Ludovic Court=C3=A8s wrote:
> Hi Ivan,
>=20
> Ivan Vilata i Balaguer <ivan@HIDDEN> skribis:
>=20
> > Hi, I'm using patchelf 0.8 from Guix commit 7f81cce3 on Debian Sid.  Wh=
en
> > trying to patch the `go` binary from
> > <https://dl.google.com/go/go1.12.3.linux-amd64.tar.gz>, I get the follo=
wing
> > error:
> >
> >     ivan@sax /tmp/tmps2Cv6w [env]$ patchelf --print-interpreter $SHELL
> >     /gnu/store/ahqgl4h89xqj695lgqvsaf6zh2nhy4pj-glibc-2.29/lib/ld-linux=
-x86-64.so.2
> >     ivan@sax /tmp/tmps2Cv6w [env]$ patchelf --set-interpreter $(patchel=
f --print-interpreter $SHELL) /tmp/tmps2Cv6w/golang/bin/go
> >     patchelf: patchelf.cc:701: void ElfFile<Elf_Ehdr, Elf_Phdr, Elf_Shd=
r, Elf_Addr, Elf_Off, Elf_Dyn, Elf_Sym>::rewriteSectionsExecutable() \
> >      [with Elf_Ehdr =3D Elf64_Ehdr; Elf_Phdr =3D Elf64_Phdr; Elf_Shdr =
=3D Elf64_Shdr; Elf_Addr =3D long unsigned int; Elf_Off =3D long unsigned i=
nt; \
> >      Elf_Dyn =3D Elf64_Dyn; Elf_Sym =3D Elf64_Sym]: Assertion `(off_t) =
rdi(hdr->e_shoff) >=3D startOffset' failed.
> >     Aborted
>=20
> I think it=E2=80=99s a bug you should report upstream to the PatchELF
> maintainers; it=E2=80=99s probably not Guix-specific.
>=20

On the other hand, if I were the patchelf maintainers, I'd suggest
upgrading our package from 0.8 to a newer version.

--=20
Efraim Flashner   <efraim@HIDDEN>   =D7=90=D7=A4=D7=A8=D7=99=D7=9D =
=D7=A4=D7=9C=D7=A9=D7=A0=D7=A8
GPG key =3D A28B F40C 3E55 1372 662D  14F7 41AA E7DC CA3D 8351
Confidentiality cannot be guaranteed on emails sent or received unencrypted

--FLPM4o+7JoHGki3m
Content-Type: application/pgp-signature; name="signature.asc"

-----BEGIN PGP SIGNATURE-----

iQIzBAABCgAdFiEEoov0DD5VE3JmLRT3Qarn3Mo9g1EFAl3BoMsACgkQQarn3Mo9
g1HZ6A/+NFxHrliqlxDzdAAOwYDGYRiOIgP0B7RyQSo0RC84f49Hb/hpGBIcwoJb
DjJh+/KI28fsVSo2KppcSOhsB+x9uVxOTYUZnRmWNDQtN8njTEm7bkuy1QXY5h3e
P7VgcdecTAjpmOJp1OLsPxigdIFK8wYkIga+FnUCM2C53Dl9aOBVI+XGH/4V4Klr
vZ7GvJNaGhbot5WBAWca7LMXryz8LmWdhgs2yZJOpbnYmSmKapXxyl/TH7Tsq/xI
+7HjXqYxiGgjNbu7z2FYzvS3+8b0nXX1c+yJ98C+mCG/WvFdr/bl35Fd0hKqRsK7
ms6IedVtuwUXy52XTMFCy09xciHVc5avzk9OIUBeOsJ/dHb7CveSRC7wReUjXr4c
35OEljICl3/915tHs5oyjg31gu/fD3AvP0Y64WMifwFNsJtEIGs2etcSrFY1yJ5H
c7qbpqC294L3upywzZHpxjgaXA93HgTONmeTxqG0FE4C+8HU3tCgUKSQ/p3k90la
LeYXKj3RjBBfmW9Dx52+FWUWOFcoLjx/wA1I37tVA/2mnqPophXks7eTyy5xN+B0
q1DXHTe5mgyem9anV2m5hzT9SPhkl8JJWZ8pVMwNNZXf8oWOaVD6Jah14GmqIT2z
gDWaNDFX1EV+DwjO8fzmMkgpV/P5/ANahcVtZs7w47+S8Hfr+7w=
=vqlY
-----END PGP SIGNATURE-----

--FLPM4o+7JoHGki3m--




Information forwarded to bug-guix@HIDDEN:
bug#38055; Package guix. Full text available.

Message received at 38055 <at> debbugs.gnu.org:


Received: (at 38055) by debbugs.gnu.org; 5 Nov 2019 14:12:41 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Nov 05 09:12:41 2019
Received: from localhost ([127.0.0.1]:38002 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1iRzZW-0006pT-VZ
	for submit <at> debbugs.gnu.org; Tue, 05 Nov 2019 09:12:41 -0500
Received: from eggs.gnu.org ([209.51.188.92]:38655)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <ludo@HIDDEN>) id 1iRzZR-0006pA-JM
 for 38055 <at> debbugs.gnu.org; Tue, 05 Nov 2019 09:12:34 -0500
Received: from fencepost.gnu.org ([2001:470:142:3::e]:50895)
 by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from <ludo@HIDDEN>)
 id 1iRzZK-0004Lq-VS; Tue, 05 Nov 2019 09:12:27 -0500
Received: from [2001:660:6102:320:e120:2c8f:8909:cdfe] (port=53002 helo=ribbon)
 by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256)
 (Exim 4.82) (envelope-from <ludo@HIDDEN>)
 id 1iRzZJ-0003tB-Ah; Tue, 05 Nov 2019 09:12:25 -0500
From: =?utf-8?Q?Ludovic_Court=C3=A8s?= <ludo@HIDDEN>
To: Ivan Vilata i Balaguer <ivan@HIDDEN>
Subject: Re: bug#38055: patchelf: Assertion failed when setting interpreter
References: <20191104045614.GI17621@HIDDEN>
Date: Tue, 05 Nov 2019 15:12:23 +0100
In-Reply-To: <20191104045614.GI17621@HIDDEN> (Ivan Vilata
 i. Balaguer's message of "Sun, 3 Nov 2019 23:56:14 -0500")
Message-ID: <87muda1kfs.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 38055
Cc: 38055 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

Hi Ivan,

Ivan Vilata i Balaguer <ivan@HIDDEN> skribis:

> Hi, I'm using patchelf 0.8 from Guix commit 7f81cce3 on Debian Sid.  When
> trying to patch the `go` binary from
> <https://dl.google.com/go/go1.12.3.linux-amd64.tar.gz>, I get the followi=
ng
> error:
>
>     ivan@sax /tmp/tmps2Cv6w [env]$ patchelf --print-interpreter $SHELL
>     /gnu/store/ahqgl4h89xqj695lgqvsaf6zh2nhy4pj-glibc-2.29/lib/ld-linux-x=
86-64.so.2
>     ivan@sax /tmp/tmps2Cv6w [env]$ patchelf --set-interpreter $(patchelf =
--print-interpreter $SHELL) /tmp/tmps2Cv6w/golang/bin/go
>     patchelf: patchelf.cc:701: void ElfFile<Elf_Ehdr, Elf_Phdr, Elf_Shdr,=
 Elf_Addr, Elf_Off, Elf_Dyn, Elf_Sym>::rewriteSectionsExecutable() \
>      [with Elf_Ehdr =3D Elf64_Ehdr; Elf_Phdr =3D Elf64_Phdr; Elf_Shdr =3D=
 Elf64_Shdr; Elf_Addr =3D long unsigned int; Elf_Off =3D long unsigned int;=
 \
>      Elf_Dyn =3D Elf64_Dyn; Elf_Sym =3D Elf64_Sym]: Assertion `(off_t) rd=
i(hdr->e_shoff) >=3D startOffset' failed.
>     Aborted

I think it=E2=80=99s a bug you should report upstream to the PatchELF
maintainers; it=E2=80=99s probably not Guix-specific.

Thanks,
Ludo=E2=80=99.




Information forwarded to bug-guix@HIDDEN:
bug#38055; Package guix. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 4 Nov 2019 04:57:16 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Nov 03 23:57:16 2019
Received: from localhost ([127.0.0.1]:35733 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1iRUQW-0001T2-3M
	for submit <at> debbugs.gnu.org; Sun, 03 Nov 2019 23:57:16 -0500
Received: from lists.gnu.org ([209.51.188.17]:60302)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <ivan@HIDDEN>) id 1iRUQU-0001Ss-3s
 for submit <at> debbugs.gnu.org; Sun, 03 Nov 2019 23:57:14 -0500
Received: from eggs.gnu.org ([2001:470:142:3::10]:37838)
 by lists.gnu.org with esmtp (Exim 4.90_1)
 (envelope-from <ivan@HIDDEN>) id 1iRUQS-0007OH-Tl
 for bug-guix@HIDDEN; Sun, 03 Nov 2019 23:57:13 -0500
X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org
X-Spam-Level: 
X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,URIBL_BLOCKED
 autolearn=disabled version=3.3.2
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <ivan@HIDDEN>) id 1iRUQR-0000d3-Im
 for bug-guix@HIDDEN; Sun, 03 Nov 2019 23:57:12 -0500
Received: from lev.selidor.net ([2600:3c03:e001:1100::1]:56996)
 by eggs.gnu.org with esmtp (Exim 4.71)
 (envelope-from <ivan@HIDDEN>) id 1iRUQR-0000cq-FP
 for bug-guix@HIDDEN; Sun, 03 Nov 2019 23:57:11 -0500
Received: from sax.terramar.selidor.net (unknown
 [IPv6:2600:3c03:e001:114e:b029:6a28:83ac:1d43])
 by lev.selidor.net (Postfix) with ESMTP id 0D21AC88F;
 Mon,  4 Nov 2019 04:57:10 +0000 (UTC)
Received: by sax.terramar.selidor.net (Postfix, from userid 1000)
 id D8C289A6F80; Sun,  3 Nov 2019 23:56:14 -0500 (EST)
Date: Sun, 3 Nov 2019 23:56:14 -0500
From: Ivan Vilata i Balaguer <ivan@HIDDEN>
To: bug-guix@HIDDEN
Subject: patchelf: Assertion failed when setting interpreter
Message-ID: <20191104045614.GI17621@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
User-Agent: Mutt/1.12.2 (2019-09-21)
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
 recognized.
X-Received-From: 2600:3c03:e001:1100::1
X-Spam-Score: -1.4 (-)
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -2.4 (--)

Hi, I'm using patchelf 0.8 from Guix commit 7f81cce3 on Debian Sid.  When
trying to patch the `go` binary from
<https://dl.google.com/go/go1.12.3.linux-amd64.tar.gz>, I get the following
error:

    ivan@sax /tmp/tmps2Cv6w [env]$ patchelf --print-interpreter $SHELL
    /gnu/store/ahqgl4h89xqj695lgqvsaf6zh2nhy4pj-glibc-2.29/lib/ld-linux-x86-64.so.2
    ivan@sax /tmp/tmps2Cv6w [env]$ patchelf --set-interpreter $(patchelf --print-interpreter $SHELL) /tmp/tmps2Cv6w/golang/bin/go
    patchelf: patchelf.cc:701: void ElfFile<Elf_Ehdr, Elf_Phdr, Elf_Shdr, Elf_Addr, Elf_Off, Elf_Dyn, Elf_Sym>::rewriteSectionsExecutable() \
     [with Elf_Ehdr = Elf64_Ehdr; Elf_Phdr = Elf64_Phdr; Elf_Shdr = Elf64_Shdr; Elf_Addr = long unsigned int; Elf_Off = long unsigned int; \
     Elf_Dyn = Elf64_Dyn; Elf_Sym = Elf64_Sym]: Assertion `(off_t) rdi(hdr->e_shoff) >= startOffset' failed.
    Aborted

(I know Go is packed for Guix, my need arises from trying to build an
unrelated project which relies on binary Go for its build process.)

It may be the problem described here regarding Go-produced binaries:
<https://github.com/NixOS/patchelf/issues/66>.  It seems to be fixed in
patchelf 0.10, and indeed trying the same operation with patchelf 0.10 from
Debian does succeed to patch the binary.

As an aside, I tried to build `--with-source` for 0.10 and it succeeds to
compile, but tests fail to pass.

Thank you very much!

-- 
Ivan Vilata i Balaguer -- https://elvil.net/




Acknowledgement sent to Ivan Vilata i Balaguer <ivan@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-guix@HIDDEN. Full text available.
Report forwarded to bug-guix@HIDDEN:
bug#38055; Package guix. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Mon, 11 Nov 2019 15:30:02 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.