Script 'mail_helper' called by obssrc
Hello community,

here is the log from the commit of package patchelf for openSUSE:Factory 
checked in at 2022-07-26 19:42:30
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/patchelf (Old)
 and      /work/SRC/openSUSE:Factory/.patchelf.new.1533 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "patchelf"

Tue Jul 26 19:42:30 2022 rev:17 rq:990905 version:0.15.0

Changes:
--------
--- /work/SRC/openSUSE:Factory/patchelf/patchelf.changes        2022-03-28 
16:59:11.892858278 +0200
+++ /work/SRC/openSUSE:Factory/.patchelf.new.1533/patchelf.changes      
2022-07-26 19:42:43.363582226 +0200
@@ -1,0 +2,12 @@
+Fri Jul 22 22:13:20 UTC 2022 - Dirk M??ller <dmuel...@suse.com>
+
+- update to 0.15.0:
+  * Add --add-debug option
+  * Add O_BINARY flag when opening files to allow compilation for Windows
+  * Document --print-needed
+  * modifyRPath: return early if new and old rpath are empty
+  * Add comment explaining calculation for DT_MIPS_RLD_MAP_REL
+  * Add --no-sort option
+  * Handle DT_MIPS_XHASH and .MIPS.xhash  
+  
+-------------------------------------------------------------------

Old:
----
  patchelf-0.14.5.tar.bz2

New:
----
  patchelf-0.15.0.tar.bz2

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ patchelf.spec ++++++
--- /var/tmp/diff_new_pack.rXzTK9/_old  2022-07-26 19:42:43.771519190 +0200
+++ /var/tmp/diff_new_pack.rXzTK9/_new  2022-07-26 19:42:43.775518572 +0200
@@ -17,7 +17,7 @@
 
 
 Name:           patchelf
-Version:        0.14.5
+Version:        0.15.0
 Release:        0
 Summary:        A utility for patching ELF binaries
 License:        GPL-3.0-only

++++++ patchelf-0.14.5.tar.bz2 -> patchelf-0.15.0.tar.bz2 ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/patchelf-0.14.5/configure 
new/patchelf-0.15.0/configure
--- old/patchelf-0.14.5/configure       2022-02-21 14:27:37.000000000 +0100
+++ new/patchelf-0.15.0/configure       2022-07-16 07:23:27.000000000 +0200
@@ -1,6 +1,6 @@
 #! /bin/sh
 # Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.71 for patchelf 0.14.5.
+# Generated by GNU Autoconf 2.71 for patchelf 0.15.0.
 #
 #
 # Copyright (C) 1992-1996, 1998-2017, 2020-2021 Free Software Foundation,
@@ -607,8 +607,8 @@
 # Identity of this package.
 PACKAGE_NAME='patchelf'
 PACKAGE_TARNAME='patchelf'
-PACKAGE_VERSION='0.14.5'
-PACKAGE_STRING='patchelf 0.14.5'
+PACKAGE_VERSION='0.15.0'
+PACKAGE_STRING='patchelf 0.15.0'
 PACKAGE_BUGREPORT=''
 PACKAGE_URL=''
 
@@ -1285,7 +1285,7 @@
   # Omit some internal or obsolete options to make the list less imposing.
   # This message is too long to be a string in the A/UX 3.1 sh.
   cat <<_ACEOF
-\`configure' configures patchelf 0.14.5 to adapt to many kinds of systems.
+\`configure' configures patchelf 0.15.0 to adapt to many kinds of systems.
 
 Usage: $0 [OPTION]... [VAR=VALUE]...
 
@@ -1352,7 +1352,7 @@
 
 if test -n "$ac_init_help"; then
   case $ac_init_help in
-     short | recursive ) echo "Configuration of patchelf 0.14.5:";;
+     short | recursive ) echo "Configuration of patchelf 0.15.0:";;
    esac
   cat <<\_ACEOF
 
@@ -1456,7 +1456,7 @@
 test -n "$ac_init_help" && exit $ac_status
 if $ac_init_version; then
   cat <<\_ACEOF
-patchelf configure 0.14.5
+patchelf configure 0.15.0
 generated by GNU Autoconf 2.71
 
 Copyright (C) 2021 Free Software Foundation, Inc.
@@ -1571,7 +1571,7 @@
 This file contains any messages produced by compilers while
 running configure, to aid debugging if configure makes a mistake.
 
-It was created by patchelf $as_me 0.14.5, which was
+It was created by patchelf $as_me 0.15.0, which was
 generated by GNU Autoconf 2.71.  Invocation command line was
 
   $ $0$ac_configure_args_raw
@@ -3049,7 +3049,7 @@
 
 # Define the identity of the package.
  PACKAGE='patchelf'
- VERSION='0.14.5'
+ VERSION='0.15.0'
 
 
 printf "%s\n" "#define PACKAGE \"$PACKAGE\"" >>confdefs.h
@@ -5757,7 +5757,7 @@
 # report actual input values of CONFIG_FILES etc. instead of their
 # values after options handling.
 ac_log="
-This file was extended by patchelf $as_me 0.14.5, which was
+This file was extended by patchelf $as_me 0.15.0, which was
 generated by GNU Autoconf 2.71.  Invocation command line was
 
   CONFIG_FILES    = $CONFIG_FILES
@@ -5816,7 +5816,7 @@
 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
 ac_cs_config='$ac_cs_config_escaped'
 ac_cs_version="\\
-patchelf config.status 0.14.5
+patchelf config.status 0.15.0
 configured by $0, generated by GNU Autoconf 2.71,
   with options \\"\$ac_cs_config\\"
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/patchelf-0.14.5/patchelf.1 
new/patchelf-0.15.0/patchelf.1
--- old/patchelf-0.14.5/patchelf.1      1970-01-01 01:00:01.000000000 +0100
+++ new/patchelf-0.15.0/patchelf.1      1970-01-01 01:00:01.000000000 +0100
@@ -85,10 +85,25 @@
 Removes a declared dependency on LIBRARY (DT_NEEDED entry). This
 option can be given multiple times.
 
+.IP --print-needed
+Prints all DT_NEEDED entries of the executable.
+
 .IP "--no-default-lib"
 Marks the object so that the search for dependencies of this object will 
ignore any
 default library search paths.
 
+.IP "--no-sort"
+Do not sort program headers or section headers.  This is useful when
+debugging patchelf, because it makes it easier to read diffs of the
+output of "readelf -a".
+
+.IP "--add-debug-tag"
+Adds DT_DEBUG tag to the .dynamic section if not yet present in an ELF
+object. A shared library (-shared) by default does not receive DT_DEBUG tag.
+This means that when a shared library has an entry point (so that it
+can be run as an executable), the debugger does not connect to it correctly and
+symbols are not resolved.
+
 .IP "--output FILE"
 Set the output file name.  If not specified, the input will be modified in 
place.
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/patchelf-0.14.5/patchelf.spec 
new/patchelf-0.15.0/patchelf.spec
--- old/patchelf-0.14.5/patchelf.spec   2022-02-21 14:27:39.000000000 +0100
+++ new/patchelf-0.15.0/patchelf.spec   2022-07-16 07:23:29.000000000 +0200
@@ -1,7 +1,7 @@
 Summary: A utility for patching ELF binaries
 
 Name: patchelf
-Version: 0.14.5
+Version: 0.15.0
 Release: 1
 License: GPL
 Group: Development/Tools
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/patchelf-0.14.5/src/elf.h 
new/patchelf-0.15.0/src/elf.h
--- old/patchelf-0.14.5/src/elf.h       1970-01-01 01:00:01.000000000 +0100
+++ new/patchelf-0.15.0/src/elf.h       1970-01-01 01:00:01.000000000 +0100
@@ -1400,6 +1400,7 @@
 #define SHT_MIPS_EH_REGION     0x70000027
 #define SHT_MIPS_XLATE_OLD     0x70000028
 #define SHT_MIPS_PDR_EXCEPTION 0x70000029
+#define SHT_MIPS_XHASH          0x7000002b
 
 /* Legal values for sh_flags field of Elf32_Shdr.  */
 
@@ -1647,7 +1648,9 @@
    in a PIE as it stores a relative offset from the address of the tag
    rather than an absolute address.  */
 #define DT_MIPS_RLD_MAP_REL  0x70000035
-#define DT_MIPS_NUM          0x36
+/* GNU-style hash table with xlat.  */
+#define DT_MIPS_XHASH        0x70000036
+#define DT_MIPS_NUM          0x37
 
 /* Legal values for DT_MIPS_FLAGS Elf32_Dyn entry.  */
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/patchelf-0.14.5/src/patchelf.cc 
new/patchelf-0.15.0/src/patchelf.cc
--- old/patchelf-0.14.5/src/patchelf.cc 1970-01-01 01:00:01.000000000 +0100
+++ new/patchelf-0.15.0/src/patchelf.cc 1970-01-01 01:00:01.000000000 +0100
@@ -47,6 +47,11 @@
 #define PACKAGE_STRING "patchelf"
 #endif
 
+// This is needed for Windows/mingw
+#ifndef O_BINARY
+#define O_BINARY 0
+#endif
+
 static bool debugMode = false;
 
 static bool forceRPath = false;
@@ -164,7 +169,7 @@
 
     FileContents contents = std::make_shared<std::vector<unsigned char>>(size);
 
-    int fd = open(fileName.c_str(), O_RDONLY);
+    int fd = open(fileName.c_str(), O_RDONLY | O_BINARY);
     if (fd == -1) throw SysError(fmt("opening '", fileName, "'"));
 
     size_t bytesRead = 0;
@@ -375,7 +380,7 @@
 {
     debug("writing %s\n", fileName.c_str());
 
-    int fd = open(fileName.c_str(), O_CREAT | O_TRUNC | O_WRONLY, 0777);
+    int fd = open(fileName.c_str(), O_CREAT | O_TRUNC | O_WRONLY | O_BINARY, 
0777);
     if (fd == -1)
         error("open");
 
@@ -730,14 +735,16 @@
     rewriteHeaders(firstPage + rdi(hdr()->e_phoff));
 }
 
+static bool noSort = false;
 
 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();
-
+    if (!noSort) {
+        /* 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;
@@ -950,7 +957,9 @@
         }
     }
 
-    sortPhdrs();
+    if (!noSort) {
+        sortPhdrs();
+    }
 
     for (unsigned int i = 0; i < phdrs.size(); ++i)
         * ((Elf_Phdr *) (fileContents->data() + rdi(hdr()->e_phoff)) + i) = 
phdrs.at(i);
@@ -959,7 +968,9 @@
     /* Rewrite the section header table.  For neatness, keep the
        sections sorted. */
     assert(rdi(hdr()->e_shnum) == shdrs.size());
-    sortShdrs();
+    if (!noSort) {
+        sortShdrs();
+    }
     for (unsigned int i = 1; i < rdi(hdr()->e_shnum); ++i)
         * ((Elf_Shdr *) (fileContents->data() + rdi(hdr()->e_shoff)) + i) = 
shdrs.at(i);
 
@@ -985,6 +996,10 @@
                 // some binaries might this section stripped
                 // in which case we just ignore the value.
                 if (shdr) dyn->d_un.d_ptr = (*shdr).get().sh_addr;
+            } else if (d_tag == DT_MIPS_XHASH) {
+                // the .MIPS.xhash section was added to the glibc-ABI
+                // in commit 23c1c256ae7b0f010d0fcaff60682b620887b164
+                dyn->d_un.d_ptr = findSectionHeader(".MIPS.xhash").sh_addr;
             } else if (d_tag == DT_JMPREL) {
                 auto shdr = tryFindSectionHeader(".rel.plt");
                 if (!shdr) shdr = tryFindSectionHeader(".rela.plt");
@@ -1019,6 +1034,16 @@
                    pointer, relative to the address of the tag */
                 auto shdr = tryFindSectionHeader(".rld_map");
                 if (shdr) {
+                    /*
+                     * "When correct, (DT_MIPS_RLD_MAP_REL + tag offset + 
executable base address) equals DT_MIPS_RLD_MAP"
+                     * -- 
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=820334#5
+                     *
+                     * Equivalently,
+                     *
+                     *   DT_MIPS_RLD_MAP_REL + tag offset + executable base 
address == DT_MIPS_RLD_MAP
+                     *   DT_MIPS_RLD_MAP_REL              + executable base 
address == DT_MIPS_RLD_MAP - tag_offset
+                     *   DT_MIPS_RLD_MAP_REL                                   
     == DT_MIPS_RLD_MAP - tag_offset - executable base address
+                     */
                     auto rld_map_addr = findSectionHeader(".rld_map").sh_addr;
                     auto dyn_offset = ((char*)dyn) - ((char*)dyn_table);
                     dyn->d_un.d_ptr = rld_map_addr - dyn_offset - 
(*shdrDynamic).get().sh_addr;
@@ -1345,8 +1370,8 @@
     debug("new rpath is '%s'\n", newRPath.c_str());
 
 
-    if (rpath && newRPath.size() <= rpathSize) {
-        memcpy(rpath, newRPath.c_str(), newRPath.size() + 1);
+    if (newRPath.size() <= rpathSize) {
+        if (rpath) memcpy(rpath, newRPath.c_str(), newRPath.size() + 1);
         return;
     }
 
@@ -1653,6 +1678,38 @@
 }
 
 template<ElfFileParams>
+void ElfFile<ElfFileParamNames>::addDebugTag()
+{
+    auto shdrDynamic = findSectionHeader(".dynamic");
+
+    auto dyn = (Elf_Dyn *)(fileContents->data() + rdi(shdrDynamic.sh_offset));
+    for ( ; rdi(dyn->d_tag) != DT_NULL; dyn++) {
+        if (rdi(dyn->d_tag) == DT_DEBUG) {
+            return;
+        }
+    }
+    std::string & newDynamic = replaceSection(".dynamic",
+            rdi(shdrDynamic.sh_size) + sizeof(Elf_Dyn));
+
+    unsigned int idx = 0;
+    for ( ; rdi(((Elf_Dyn *) newDynamic.c_str())[idx].d_tag) != DT_NULL; 
idx++) ;
+    debug("DT_NULL index is %d\n", idx);
+
+    /* Shift all entries down by one. */
+    setSubstr(newDynamic, sizeof(Elf_Dyn),
+            std::string(newDynamic, 0, sizeof(Elf_Dyn) * (idx + 1)));
+
+    /* Add the DT_DEBUG entry at the top. */
+    Elf_Dyn newDyn;
+    wri(newDyn.d_tag, DT_DEBUG);
+    newDyn.d_un.d_val = 0;
+    setSubstr(newDynamic, 0, std::string((char *) &newDyn, sizeof(Elf_Dyn)));
+
+    this->rewriteSections();
+    changed = true;
+}
+
+template<ElfFileParams>
 void ElfFile<ElfFileParamNames>::clearSymbolVersions(const 
std::set<std::string> & syms)
 {
     if (syms.empty()) return;
@@ -1691,6 +1748,7 @@
 static bool removeRPath = false;
 static bool setRPath = false;
 static bool addRPath = false;
+static bool addDebugTag = false;
 static bool printRPath = false;
 static std::string newRPath;
 static std::set<std::string> neededLibsToRemove;
@@ -1737,6 +1795,9 @@
     if (noDefaultLib)
         elfFile.noDefaultLib();
 
+    if (addDebugTag)
+        elfFile.addDebugTag();
+
     if (elfFile.isChanged()){
         writeFile(fileName, elfFile.fileContents);
     } else if (alwaysWrite) {
@@ -1792,7 +1853,9 @@
   [--replace-needed LIBRARY NEW_LIBRARY]\n\
   [--print-needed]\n\
   [--no-default-lib]\n\
+  [--no-sort]\t\tDo not sort program+section headers; useful for debugging 
patchelf.\n\
   [--clear-symbol-version SYMBOL]\n\
+  [--add-debug-tag]\n\
   [--output FILE]\n\
   [--debug]\n\
   [--version]\n\
@@ -1873,6 +1936,9 @@
         else if (arg == "--print-needed") {
             printNeeded = true;
         }
+        else if (arg == "--no-sort") {
+            noSort = true;
+        }
         else if (arg == "--add-needed") {
             if (++i == argc) error("missing argument");
             neededLibsToAdd.insert(resolveArgument(argv[i]));
@@ -1901,6 +1967,9 @@
         else if (arg == "--no-default-lib") {
             noDefaultLib = true;
         }
+        else if (arg == "--add-debug-tag") {
+            addDebugTag = true;
+        }
         else if (arg == "--help" || arg == "-h" ) {
             showHelp(argv[0]);
             return 0;
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/patchelf-0.14.5/src/patchelf.h 
new/patchelf-0.15.0/src/patchelf.h
--- old/patchelf-0.14.5/src/patchelf.h  1970-01-01 01:00:01.000000000 +0100
+++ new/patchelf-0.15.0/src/patchelf.h  1970-01-01 01:00:01.000000000 +0100
@@ -131,6 +131,8 @@
 
     void noDefaultLib();
 
+    void addDebugTag();
+
     void clearSymbolVersions(const std::set<std::string> & syms);
 
 private:
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/patchelf-0.14.5/tests/Makefile.am 
new/patchelf-0.15.0/tests/Makefile.am
--- old/patchelf-0.14.5/tests/Makefile.am       1970-01-01 01:00:01.000000000 
+0100
+++ new/patchelf-0.15.0/tests/Makefile.am       1970-01-01 01:00:01.000000000 
+0100
@@ -40,7 +40,8 @@
   set-empty-rpath.sh \
   phdr-corruption.sh \
   replace-needed.sh \
-  replace-add-needed.sh
+  replace-add-needed.sh \
+  add-debug-tag.sh
 
 build_TESTS = \
   $(no_rpath_arch_TESTS)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/patchelf-0.14.5/tests/Makefile.in 
new/patchelf-0.15.0/tests/Makefile.in
--- old/patchelf-0.14.5/tests/Makefile.in       2022-02-21 14:27:38.000000000 
+0100
+++ new/patchelf-0.15.0/tests/Makefile.in       2022-07-16 07:23:27.000000000 
+0200
@@ -604,7 +604,8 @@
   set-empty-rpath.sh \
   phdr-corruption.sh \
   replace-needed.sh \
-  replace-add-needed.sh
+  replace-add-needed.sh \
+  add-debug-tag.sh
 
 build_TESTS = \
   $(no_rpath_arch_TESTS)
@@ -1273,6 +1274,13 @@
        $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
        --log-file $$b.log --trs-file $$b.trs \
        $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) 
-- $(LOG_COMPILE) \
+       "$$tst" $(AM_TESTS_FD_REDIRECT)
+add-debug-tag.sh.log: add-debug-tag.sh
+       @p='add-debug-tag.sh'; \
+       b='add-debug-tag.sh'; \
+       $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
+       --log-file $$b.log --trs-file $$b.trs \
+       $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) 
-- $(LOG_COMPILE) \
        "$$tst" $(AM_TESTS_FD_REDIRECT)
 no-rpath-amd64.sh.log: no-rpath-amd64.sh
        @p='no-rpath-amd64.sh'; \
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/patchelf-0.14.5/tests/add-debug-tag.sh 
new/patchelf-0.15.0/tests/add-debug-tag.sh
--- old/patchelf-0.14.5/tests/add-debug-tag.sh  1970-01-01 01:00:00.000000000 
+0100
+++ new/patchelf-0.15.0/tests/add-debug-tag.sh  1970-01-01 01:00:01.000000000 
+0100
@@ -0,0 +1,26 @@
+#! /bin/sh -e
+SCRATCH=scratch/$(basename $0 .sh)
+
+rm -rf ${SCRATCH}
+mkdir -p ${SCRATCH}
+
+cp libsimple.so ${SCRATCH}/
+
+# check there is no DT_DEBUG tag
+debugTag=$(readelf -d ${SCRATCH}/libsimple.so)
+echo ".dynamic before: $debugTag"
+if echo "$debugTag" | grep -q DEBUG; then
+    echo "failed --add-debug-tag test. Expected no line with (DEBUG), got: 
$debugTag"
+    exit 1
+fi
+
+# set DT_DEBUG
+../src/patchelf --add-debug-tag ${SCRATCH}/libsimple.so
+
+# check there is DT_DEBUG tag
+debugTag=$(readelf -d ${SCRATCH}/libsimple.so)
+echo ".dynamic before: $debugTag"
+if ! echo "$debugTag" | grep -q DEBUG; then
+    echo "failed --add-debug-tag test. Expected line with (DEBUG), got: 
$debugTag"
+    exit 1
+fi
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/patchelf-0.14.5/version new/patchelf-0.15.0/version
--- old/patchelf-0.14.5/version 2022-02-21 14:27:35.000000000 +0100
+++ new/patchelf-0.15.0/version 2022-07-16 07:23:25.000000000 +0200
@@ -1 +1 @@
-0.14.5
+0.15.0

Reply via email to