pkgsrc-Changes archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

CVS commit: pkgsrc/devel/patchelf



Module Name:    pkgsrc
Committed By:   pho
Date:           Wed Nov 25 10:04:05 UTC 2026

Modified Files:
        pkgsrc/devel/patchelf: Makefile distinfo
        pkgsrc/devel/patchelf/patches: patch-src_patchelf.cc
Added Files:
        pkgsrc/devel/patchelf/patches: patch-src_elf.h patch-src_patchelf.h

Log Message:
devel/patchelf: Fix a runtime issue on SunOS (again)

Turned out my previous fix was incomplete, as there were more sections that
needed to update. This time it *should* be working.


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 pkgsrc/devel/patchelf/Makefile
cvs rdiff -u -r1.20 -r1.21 pkgsrc/devel/patchelf/distinfo
cvs rdiff -u -r0 -r1.1 pkgsrc/devel/patchelf/patches/patch-src_elf.h \
    pkgsrc/devel/patchelf/patches/patch-src_patchelf.h
cvs rdiff -u -r1.1 -r1.2 pkgsrc/devel/patchelf/patches/patch-src_patchelf.cc

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: pkgsrc/devel/patchelf/Makefile
diff -u pkgsrc/devel/patchelf/Makefile:1.23 pkgsrc/devel/patchelf/Makefile:1.24
--- pkgsrc/devel/patchelf/Makefile:1.23 Wed Nov 11 13:38:36 2026
+++ pkgsrc/devel/patchelf/Makefile      Wed Nov 25 10:04:05 2026
@@ -1,7 +1,7 @@
-# $NetBSD: Makefile,v 1.23 2026/11/11 13:38:36 pho Exp $
+# $NetBSD: Makefile,v 1.24 2026/11/25 10:04:05 pho Exp $
 
 DISTNAME=      patchelf-0.19.3
-PKGREVISION=   1
+PKGREVISION=   2
 CATEGORIES=    devel
 MASTER_SITES=  ${MASTER_SITE_GITHUB:=NixOS/}
 GITHUB_RELEASE=        ${PKGVERSION_NOREV}

Index: pkgsrc/devel/patchelf/distinfo
diff -u pkgsrc/devel/patchelf/distinfo:1.20 pkgsrc/devel/patchelf/distinfo:1.21
--- pkgsrc/devel/patchelf/distinfo:1.20 Wed Nov 11 13:38:36 2026
+++ pkgsrc/devel/patchelf/distinfo      Wed Nov 25 10:04:05 2026
@@ -1,6 +1,8 @@
-$NetBSD: distinfo,v 1.20 2026/11/11 13:38:36 pho Exp $
+$NetBSD: distinfo,v 1.21 2026/11/25 10:04:05 pho Exp $
 
 BLAKE2s (patchelf-0.19.3.tar.bz2) = 1b8cf6105a4a0c72963b69569951fd7c700c8f6844455affe6469bca00f2c17a
 SHA512 (patchelf-0.19.3.tar.bz2) = 16ff5113b6941a326f570f8dadee40bfd975add8b1475bb00e6eb90bf341029fd61baeaf30a630a19500792ae79fb07b5a9b18d630f6734423f4ebca647e0c21
 Size (patchelf-0.19.3.tar.bz2) = 444978 bytes
-SHA1 (patch-src_patchelf.cc) = e8a95bbfc570217e4342f87d21d38ba539befdfb
+SHA1 (patch-src_elf.h) = a64552b09d62de3cdb8284104d9e3dfefce635ae
+SHA1 (patch-src_patchelf.cc) = 73713bcbab29b8cebf8dedbd06b5bec9feb35b33
+SHA1 (patch-src_patchelf.h) = 8ed5d80143b585103f68e8d2879a5a5208a4a501

Index: pkgsrc/devel/patchelf/patches/patch-src_patchelf.cc
diff -u pkgsrc/devel/patchelf/patches/patch-src_patchelf.cc:1.1 pkgsrc/devel/patchelf/patches/patch-src_patchelf.cc:1.2
--- pkgsrc/devel/patchelf/patches/patch-src_patchelf.cc:1.1     Wed Nov 11 13:38:36 2026
+++ pkgsrc/devel/patchelf/patches/patch-src_patchelf.cc Wed Nov 25 10:04:05 2026
@@ -1,25 +1,92 @@
-$NetBSD: patch-src_patchelf.cc,v 1.1 2026/11/11 13:38:36 pho Exp $
+$NetBSD: patch-src_patchelf.cc,v 1.2 2026/11/25 10:04:05 pho Exp $
 
-Fix for SunOS: There is no section ".gnu.version_r" on this platform. The
-corresponding section is ".SUNW_version".
+Fix for SunOS: There are no sections ".gnu.version_r", ".gnu.version_d", or
+".gnu.version" on this platform. The corresponding sections are
+".SUNW_version", ".SUNW_version", and ".SUNW_versym" respectively. But
+since the first two sections have the same name, we have to disambiguate
+them with a section type.
 
 TODO: Test this more thoroughly and then send a pull request to the
 upstream.
 
 --- src/patchelf.cc.orig       1970-01-01 00:00:01.000000000 +0000
 +++ src/patchelf.cc
-@@ -1425,8 +1425,12 @@ void ElfFile<ElfFileParamNames>::rewrite
+@@ -620,6 +620,16 @@ const Elf_Shdr & ElfFile<ElfFileParamNam
+     return *shdr;
+ }
+ 
++template<ElfFileParams>
++const Elf_Shdr & ElfFile<ElfFileParamNames>::findSectionHeader(Elf_Shdr_Type sectionType) const
++{
++    auto shdr = tryFindSectionHeader(sectionType);
++    if (!shdr) {
++        std::string extraMsg;
++        error(fmt("cannot find section with type " + sectionType));
++    }
++    return *shdr;
++}
+ 
+ template<ElfFileParams>
+ std::optional<std::reference_wrapper<const Elf_Shdr>> ElfFile<ElfFileParamNames>::tryFindSectionHeader(const SectionName & sectionName) const
+@@ -631,6 +641,15 @@ std::optional<std::reference_wrapper<con
+ }
+ 
+ template<ElfFileParams>
++std::optional<std::reference_wrapper<const Elf_Shdr>> ElfFile<ElfFileParamNames>::tryFindSectionHeader(Elf_Shdr_Type sectionType) const
++{
++    auto i = getSectionIndex(sectionType);
++    if (i)
++        return shdrs.at(i);
++    return {};
++}
++
++template<ElfFileParams>
+ template<class T>
+ span<T> ElfFile<ElfFileParamNames>::getSectionSpan(const Elf_Shdr & shdr) const
+ {
+@@ -674,6 +693,14 @@ unsigned int ElfFile<ElfFileParamNames>:
+ }
+ 
+ template<ElfFileParams>
++unsigned int ElfFile<ElfFileParamNames>::getSectionIndex(Elf_Shdr_Type sectionType) const
++{
++    for (unsigned int i = 1; i < rdi(hdr()->e_shnum); ++i)
++        if (rdi(shdrs.at(i).sh_type) == sectionType) return i;
++    return 0;
++}
++
++template<ElfFileParams>
+ bool ElfFile<ElfFileParamNames>::hasReplacedSection(const SectionName & sectionName) const
+ {
+     return replacedSections.count(sectionName);
+@@ -1425,12 +1452,24 @@ void ElfFile<ElfFileParamNames>::rewrite
                  if (!shdr) continue;
                  dyn->d_un.d_ptr = (*shdr).get().sh_addr;
              }
 -            else if (d_tag == DT_VERNEED)
 -                dyn->d_un.d_ptr = findSectionHeader(".gnu.version_r").sh_addr;
+-            else if (d_tag == DT_VERDEF)
+-                dyn->d_un.d_ptr = findSectionHeader(".gnu.version_d").sh_addr;
+-            else if (d_tag == DT_VERSYM)
+-                dyn->d_un.d_ptr = findSectionHeader(".gnu.version").sh_addr;
 +            else if (d_tag == DT_VERNEED) {
-+                auto shdr = tryFindSectionHeader(".gnu.version_r");
-+                if (!shdr) shdr = tryFindSectionHeader(".SUNW_version");
++                auto shdr = tryFindSectionHeader(SHT_GNU_verneed);
++                if (!shdr) shdr = tryFindSectionHeader(SHT_SUNW_verneed);
 +                if (!shdr) error("cannot find section corresponding to DT_VERNEED");
 +                dyn->d_un.d_ptr = (*shdr).get().sh_addr;
 +            }
-             else if (d_tag == DT_VERDEF)
-                 dyn->d_un.d_ptr = findSectionHeader(".gnu.version_d").sh_addr;
-             else if (d_tag == DT_VERSYM)
++            else if (d_tag == DT_VERDEF) {
++                auto shdr = tryFindSectionHeader(SHT_GNU_verdef);
++                if (!shdr) shdr = tryFindSectionHeader(SHT_SUNW_verdef);
++                if (!shdr) error("cannot find section corresponding to DT_VERDEF");
++                dyn->d_un.d_ptr = (*shdr).get().sh_addr;
++            }
++            else if (d_tag == DT_VERSYM) {
++                auto shdr = tryFindSectionHeader(SHT_GNU_versym);
++                if (!shdr) shdr = tryFindSectionHeader(SHT_SUNW_versym);
++                if (!shdr) error("cannot find section corresponding to DT_VERSYM");
++                dyn->d_un.d_ptr = (*shdr).get().sh_addr;
++            }
+             /* DT_{PREINIT,INIT,FINI}_ARRAY point at the corresponding
+                section's sh_addr and must follow it if relocated
+                (https://github.com/NixOS/patchelf/issues/639).

Added files:

Index: pkgsrc/devel/patchelf/patches/patch-src_elf.h
diff -u /dev/null pkgsrc/devel/patchelf/patches/patch-src_elf.h:1.1
--- /dev/null   Wed Nov 25 10:04:05 2026
+++ pkgsrc/devel/patchelf/patches/patch-src_elf.h       Wed Nov 25 10:04:05 2026
@@ -0,0 +1,19 @@
+$NetBSD: patch-src_elf.h,v 1.1 2026/11/25 10:04:05 pho Exp $
+
+See patches/src_patchelf.cc
+
+--- src/elf.h.orig     2026-11-25 08:28:15.064858073 +0000
++++ src/elf.h
+@@ -453,8 +453,11 @@ typedef struct
+ #define SHT_CHECKSUM    0x6ffffff8    /* Checksum for DSO content.  */
+ #define SHT_LOSUNW      0x6ffffffa    /* Sun-specific low bound.  */
+ #define SHT_SUNW_move   0x6ffffffa
+-#define SHT_SUNW_COMDAT   0x6ffffffb
++#define SHT_SUNW_COMDAT         0x6ffffffb
+ #define SHT_SUNW_syminfo  0x6ffffffc
++#define SHT_SUNW_verdef         0x6ffffffd    /* Sun-specific version definition. */
++#define SHT_SUNW_verneed  0x6ffffffe  /* Sun-specific version needs. */
++#define SHT_SUNW_versym         0x6fffffff    /* Sun-specific version symbols. */
+ #define SHT_GNU_verdef          0x6ffffffd    /* Version definition section.  */
+ #define SHT_GNU_verneed         0x6ffffffe    /* Version needs section.  */
+ #define SHT_GNU_versym          0x6fffffff    /* Version symbol table.  */
Index: pkgsrc/devel/patchelf/patches/patch-src_patchelf.h
diff -u /dev/null pkgsrc/devel/patchelf/patches/patch-src_patchelf.h:1.1
--- /dev/null   Wed Nov 25 10:04:05 2026
+++ pkgsrc/devel/patchelf/patches/patch-src_patchelf.h  Wed Nov 25 10:04:05 2026
@@ -0,0 +1,28 @@
+$NetBSD: patch-src_patchelf.h,v 1.1 2026/11/25 10:04:05 pho Exp $
+
+See patches/src_patchelf.cc
+
+--- src/patchelf.h.orig        2026-11-25 09:02:08.242999380 +0000
++++ src/patchelf.h
+@@ -107,9 +107,13 @@ private:
+ 
+     [[nodiscard]] std::string getSectionName(const Elf_Shdr & shdr) const;
+ 
++    using Elf_Shdr_Type = decltype(Elf_Shdr::sh_type);
++
+     const Elf_Shdr & findSectionHeader(const SectionName & sectionName) const;
++    const Elf_Shdr & findSectionHeader(Elf_Shdr_Type sectionType) const;
+ 
+     [[nodiscard]] std::optional<std::reference_wrapper<const Elf_Shdr>> tryFindSectionHeader(const SectionName & sectionName) const;
++    [[nodiscard]] std::optional<std::reference_wrapper<const Elf_Shdr>> tryFindSectionHeader(Elf_Shdr_Type sectionType) const;
+ 
+     template<class T> span<T> getSectionSpan(const Elf_Shdr & shdr) const;
+     template<class T> span<T> getSectionSpan(const SectionName & sectionName);
+@@ -117,6 +121,7 @@ private:
+     span<char> getStrTab(const Elf_Shdr & shdr) const;
+ 
+     [[nodiscard]] unsigned int getSectionIndex(const SectionName & sectionName) const;
++    [[nodiscard]] unsigned int getSectionIndex(Elf_Shdr_Type sectionType) const;
+ 
+     std::string & replaceSection(const SectionName & sectionName,
+         unsigned int size);



Home | Main Index | Thread Index | Old Index