From fche@redhat.com  Tue Oct  1 21:32:05 2024
From: fche@redhat.com (Frank Ch. Eigler)
Date: Tue, 1 Oct 2024 17:32:05 -0400
Subject: [patch] switch to xxhash for buildid recomputation
In-Reply-To: <20240929213922.GH3393@gnu.wildebeest.org>
References: <20240927191441.GF15164@redhat.com>
 <20240929213922.GH3393@gnu.wildebeest.org>
Message-ID: <20241001213205.GF25397@redhat.com>

Hi, Mark -

> I think we shouldn't zero-pad, just replace the first 128 bits. Don't
> disturb what we aren't changing. Especially since most build-ids are
> currently 160 bits (sha1), so then they would suddenly all end in 4
> zeros.

Makes sense.

> [...]
> > +# Checks for xxhash (mandatory, md5/sha1 buildid hashes are removed)
> > +AC_CHECK_HEADERS([xxhash.h], [], AC_MSG_ERROR([missing xxhash.h]))
> 
> I think this configure check it not enough.  You also want to make
> sure you have at least xxhash 0.8.0 by checking for XXH3 types or
> functions (xxhash before 0.8.0 only supported 32/64bit hashes.

Replaced with a pkgconfig check.

> [...]
> > +$CC $CFLAGS -o main main.c
> 
> Note that gcc doesn't generate build-ids unless configured with
> --enable-linker-build-id (which every distro seem to enable, but often
> isn't enabled when using a none distro gcc). So you might want to
> explicitly add -Wl,--build-id here.

Fixed.

> [...]
> > +  /* Accept any build_id_size > 0.  Hashes will be truncated or padded
> > +     to the incoming note size, as debugedit cannot change their
> > +     size. */
> > +  if (build_id_size <= 0)
> >      {
> >        error (1, 0, "Cannot handle %zu-byte build ID", build_id_size);
> >      }
> 
> Do we really want to allow really small build_ids? We really need at
> least 4 bytes, if they should be usable in the /usr/lib/.build-id
> scheme. And at least 16 bytes (128 bits) to generate universially
> unique build-ids.

They're silly small, but on the other hand, this is what the developer
wanted with the incoming binaries.  debugedit per se can handle it and
can leave policy to elsewhere.


> > @@ -3439,22 +3443,15 @@ handle_build_id (DSO *dso, Elf_Data *build_id,
> >    /* Clear the old bits so they do not affect the new hash.  */
> >    memset ((char *) build_id->d_buf + build_id_offset, 0, build_id_size);
> 
> I would use the same length as used in the memcpy below
> MIN (build_id_size, sizeof(XXH128_canonical_t))
> so we don't disturb any bits we aren't replacing.

Done.

OK, v2:


gpg: Signature made Tue 01 Oct 2024 05:28:59 PM EDT
gpg:                using RSA key 4DD136490411C0A42B28844F258B6EFA0F209D24
gpg: Good signature from "Frank Ch. Eigler <fche@elastic.org>" [ultimate]
Author: Frank Ch. Eigler <fche@redhat.com>
Date:   Tue Sep 24 15:34:44 2024 -0400

    debugedit: switch to xxhash for buildid recomputation
    
    When debugedit recomputes build-id (due to -i), it previously used md5
    or sha1 (depending on length of incoming buildid).  This patch
    replaces both those (including the code that does all the hashing)
    with a 128-bit xxhash.  The 128-bit hash is truncated or 0-padded to
    whatever the incoming ELF note width was.
    
    xxhash is much faster (8x over sha1) than either of those
    crypto-flavoured hashes, and still produces fairly collision-free
    values.  This was confirmed informally with a bulk build-id
    recomputation of a few million binaries in the debuginfod server
    corpus, yielding zero unexpected collisions.
    
    Signed-off-by: Frank Ch. Eigler <fche@redhat.com>

diff --git a/configure.ac b/configure.ac
index 999e31f39750..c4823722ea61 100644
--- a/configure.ac
+++ b/configure.ac
@@ -75,13 +75,11 @@ AC_SYS_LARGEFILE
 PKG_PROG_PKG_CONFIG
 PKG_CHECK_MODULES([LIBELF], [libelf])
 PKG_CHECK_MODULES([LIBDW], [libdw])
+PKG_CHECK_MODULES([XXHASH], [libxxhash >= 0.8.2])
 
 # Checks for header files.
 AC_CHECK_HEADERS([fcntl.h inttypes.h limits.h malloc.h stddef.h stdint.h stdlib.h string.h unistd.h])
 
-# Checks for xxhash (mandatory, md5/sha1 buildid hashes are removed)
-AC_CHECK_HEADERS([xxhash.h], [], AC_MSG_ERROR([missing xxhash.h]))
-
 # Checks for typedefs, structures, and compiler characteristics.
 AC_CHECK_HEADER_STDBOOL
 AC_C_INLINE
diff --git a/tests/debugedit.at b/tests/debugedit.at
index 4413704acc0b..68886b1f3d79 100644
--- a/tests/debugedit.at
+++ b/tests/debugedit.at
@@ -717,3 +717,43 @@ $CC $CFLAGS -gdwarf-5 -o main main.c
 AT_CHECK([[debugedit -l sources.list main]])
 AT_CHECK([[grep -q main.c sources.list]])
 AT_CLEANUP
+
+
+# ===
+# build-id recomputation
+# ===
+AT_SETUP([debugedit build-id recompute])
+AT_KEYWORDS([debuginfo] [debugedit] [build-id])
+
+# compile a test program and extract its linker-assigned build-id
+echo "int main () { }" > main.c
+$CC $CFLAGS -Wl,--build-id -o main main.c
+AT_CHECK([[$READELF -n main | grep Build.ID: | awk '{print $3}']], [0], [stdout], [ignore])
+bid="`cat stdout`"
+AT_CHECK([[expr "$bid" : '[0-9a-f]*']], [0], [ignore])
+
+# run debugedit to recompute build-id
+AT_CHECK([[debugedit -i -s deadbeef main]], [0], [stdout])
+bid2a="`cat stdout`"
+AT_CHECK([[expr "$bid2a" : '[0-9a-f]*']], [0], [ignore])
+AT_CHECK([[test "$bid" != "$bid2a"]])
+
+# check that debugedit's stdout matches readelf -n note
+AT_CHECK([[$READELF -n main | grep Build.ID: | awk '{print $3}']], [0], [stdout], [ignore])
+bid2b="`cat stdout`"
+AT_CHECK([[expr "$bid2b" : '[0-9a-f]*']], [0], [ignore])
+AT_CHECK([[test "$bid2a" == "$bid2b"]])
+
+# run debugedit to recompute build-id, check for idempotence
+AT_CHECK([[debugedit -i -s deadbeef main]], [0], [stdout])
+bid2c="`cat stdout`"
+AT_CHECK([[expr "$bid2c" : '[0-9a-f]*']], [0], [ignore])
+AT_CHECK([[test "$bid2a" == "$bid2c"]])
+
+# check that debugedit -i with different -s seed results in different valid build-id
+AT_CHECK([[debugedit -i -s zoofoo main]], [0], [stdout])
+bid3="`cat stdout`"
+AT_CHECK([[expr "$bid3" : '[0-9a-f]*']], [0], [ignore])
+AT_CHECK([[test "$bid3" != "$bid2a"]])
+
+AT_CLEANUP
diff --git a/tools/debugedit.c b/tools/debugedit.c
index 83ee755a1523..d31e8e4d2207 100644
--- a/tools/debugedit.c
+++ b/tools/debugedit.c
@@ -3440,8 +3440,14 @@ handle_build_id (DSO *dso, Elf_Data *build_id,
       || (! dirty_elf && build_id_seed == NULL))
     goto print;
 
-  /* Clear the old bits so they do not affect the new hash.  */
-  memset ((char *) build_id->d_buf + build_id_offset, 0, build_id_size);
+  /* Clear the bits about to be recomputed, so they do not affect the
+     new hash.  Extra bits left over from wider-than-128-bit hash are
+     preserved for extra entropy.  This computation should be
+     idempotent, so repeated rehashes (with the same seed) should
+     result in the same hash. */
+  XXH128_canonical_t result_canon;
+  memset ((char *) build_id->d_buf + build_id_offset, 0,
+          MIN (build_id_size, sizeof(result_canon)));
 
   XXH3_state_t* state = XXH3_createState();
   if (!state)
@@ -3519,7 +3525,6 @@ handle_build_id (DSO *dso, Elf_Data *build_id,
   XXH128_hash_t result = XXH3_128bits_digest (state);
   XXH3_freeState (state);
   /* Use canonical-endianness output. */
-  XXH128_canonical_t result_canon;
   XXH128_canonicalFromHash (&result_canon, result);
   memcpy((unsigned char *)build_id->d_buf + build_id_offset, &result_canon,
          MIN (build_id_size, sizeof(result_canon)));


From mark@klomp.org  Tue Oct  1 21:53:49 2024
From: mark@klomp.org (Mark Wielaard)
Date: Tue, 1 Oct 2024 23:53:49 +0200
Subject: [PATCH] debugedit: Handle DWARF5 DW_UT_type (Unit type 2) in
 ET_EXE/DYN
In-Reply-To: <20240928230445.390836-1-mark@klomp.org>
References: <20240928230445.390836-1-mark@klomp.org>
Message-ID: <20241001215349.GB17463@gnu.wildebeest.org>

Hi,

On Sun, Sep 29, 2024 at 01:04:45AM +0200, Mark Wielaard wrote:
> Handle DW_UT_type as if it is a DW_UT_compile unit by skipping the
> type id and offset in the header. Which are the only differences with
> DW_UT_compile. And the id and offset don't need to be rewritten. This
> doesn't handle debug types in objects or partial linked (ET_REL) files
> that contain COMDAT sections (because debugedit doesn't handle more
> than one debug_info section). Add a testcase for foobarbaz.exe.

Pushed to main.

Cheers,

Mark

From sourceware-bugzilla@sourceware.org  Tue Oct  1 21:56:38 2024
From: sourceware-bugzilla@sourceware.org (mark at klomp dot org)
Date: Tue, 01 Oct 2024 21:56:38 +0000
Subject: [Bug debugedit/32157] Handle DW_UT_TYPE units (Unit type 2)
In-Reply-To: <bug-32157-13298@http.sourceware.org/bugzilla/>
References: <bug-32157-13298@http.sourceware.org/bugzilla/>
Message-ID: <bug-32157-13298-3dggJstt3B@http.sourceware.org/bugzilla/>

https://sourceware.org/bugzilla/show_bug.cgi?id=32157

Mark Wielaard <mark at klomp dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|---                         |FIXED

--- Comment #2 from Mark Wielaard <mark at klomp dot org> ---
commit a359559d4a7696a415cfec5f924363d26cb9a4eb
Author: Mark Wielaard <mark@klomp.org>
Date:   Sat Sep 28 23:39:29 2024 +0200

    debugedit: Handle DWARF5 DW_UT_type (Unit type 2) in ET_EXE/DYN

    Handle DW_UT_type as if it is a DW_UT_compile unit by skipping the
    type id and offset in the header. Which are the only differences with
    DW_UT_compile. And the id and offset don't need to be rewritten. This
    doesn't handle debug types in objects or partial linked (ET_REL) files
    that contain COMDAT sections (because debugedit doesn't handle more
    than one debug_info section). Add a testcase for foobarbaz.exe.

    https://sourceware.org/bugzilla/show_bug.cgi?id=32157

    Signed-off-by: Mark Wielaard <mark@klomp.org>

-- 
You are receiving this mail because:
You are on the CC list for the bug.

From mark@klomp.org  Tue Oct  1 22:15:33 2024
From: mark@klomp.org (Mark Wielaard)
Date: Wed, 2 Oct 2024 00:15:33 +0200
Subject: [patch] switch to xxhash for buildid recomputation
In-Reply-To: <20241001213205.GF25397@redhat.com>
References: <20240927191441.GF15164@redhat.com>
 <20240929213922.GH3393@gnu.wildebeest.org>
 <20241001213205.GF25397@redhat.com>
Message-ID: <20241001221533.GC17463@gnu.wildebeest.org>

Hi Frank,

On Tue, Oct 01, 2024 at 05:32:05PM -0400, Frank Ch. Eigler wrote:
> > [...]
> > > +# Checks for xxhash (mandatory, md5/sha1 buildid hashes are removed)
> > > +AC_CHECK_HEADERS([xxhash.h], [], AC_MSG_ERROR([missing xxhash.h]))
> > 
> > I think this configure check it not enough.  You also want to make
> > sure you have at least xxhash 0.8.0 by checking for XXH3 types or
> > functions (xxhash before 0.8.0 only supported 32/64bit hashes.
> 
> Replaced with a pkgconfig check.

OK, but why check for libxxhash >= 0.8.2?  Isn't >= 0.8.0 enough?  It
would exclude debian stable (0.8.1) and I would really like debuginfo
to build on that.

> > [...]
> > > +  /* Accept any build_id_size > 0.  Hashes will be truncated or padded
> > > +     to the incoming note size, as debugedit cannot change their
> > > +     size. */
> > > +  if (build_id_size <= 0)
> > >      {
> > >        error (1, 0, "Cannot handle %zu-byte build ID", build_id_size);
> > >      }
> > 
> > Do we really want to allow really small build_ids? We really need at
> > least 4 bytes, if they should be usable in the /usr/lib/.build-id
> > scheme. And at least 16 bytes (128 bits) to generate universially
> > unique build-ids.
> 
> They're silly small, but on the other hand, this is what the developer
> wanted with the incoming binaries.  debugedit per se can handle it and
> can leave policy to elsewhere.

Yes, debugedit can handle it now. But before it only handled 16 or 20
byte build-ids. So restricting it to 16+ bytes isn't a regression.
But I see your point, so lets keep it accepting silly small
build-ids.

I might introduce a sanity check in the find-debuginfo script though.

> OK, v2:

well... it is more like a diff against v1, except for the testcase?
Also it isn't easy to apply locally. Could you post something with git
send-email of git format-patch?

Thanks,

Mark

From fche@redhat.com  Tue Oct  1 22:45:53 2024
From: fche@redhat.com (Frank Ch. Eigler)
Date: Tue, 1 Oct 2024 18:45:53 -0400
Subject: [patch] switch to xxhash for buildid recomputation
In-Reply-To: <20241001221533.GC17463@gnu.wildebeest.org>
References: <20240927191441.GF15164@redhat.com>
 <20240929213922.GH3393@gnu.wildebeest.org>
 <20241001213205.GF25397@redhat.com>
 <20241001221533.GC17463@gnu.wildebeest.org>
Message-ID: <20241001224553.GA27163@redhat.com>

Hi -

> > Replaced with a pkgconfig check.
> 
> OK, but why check for libxxhash >= 0.8.2?  Isn't >= 0.8.0 enough?  It
> would exclude debian stable (0.8.1) and I would really like debuginfo
> to build on that.

Even RHEL7 EPEL had 0.8.2, so I figured that was fine.  I'll change it
to 0.8.1 for our debian pals, and hope the buildbots speak up if there's
a problem.

> > OK, v2:
> 
> well... it is more like a diff against v1, except for the testcase?

Whoops, sorry, resending.


commit e89f4bdec82c4137035c1e645ac96fff2aa9a146 (HEAD -> main)
Author: Frank Ch. Eigler <fche@redhat.com>
Date:   Tue Sep 24 15:34:44 2024 -0400

    debugedit: switch to xxhash for buildid recomputation
    
    When debugedit recomputes build-id (due to -i), it previously used md5
    or sha1 (depending on length of incoming buildid).  This patch
    replaces both those (including the code that does all the hashing)
    with a 128-bit xxhash.  The 128-bit hash is truncated or padded to
    whatever the incoming ELF note width was.
    
    xxhash is much faster (8x over sha1) than either of those
    crypto-flavoured hashes, and still produces fairly collision-free
    values.  This was confirmed informally with a bulk build-id
    recomputation of a few million binaries in the debuginfod server
    corpus, yielding zero unexpected collisions.
    
    Signed-off-by: Frank Ch. Eigler <fche@redhat.com>

diff --git a/Makefile.am b/Makefile.am
index 4a5092dfcbec..c590edf94f4f 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -41,9 +41,7 @@ find-debuginfo: $(top_srcdir)/scripts/find-debuginfo.in Makefile
 	chmod +x "$@"
 
 debugedit_SOURCES = tools/debugedit.c \
-		    tools/hashtab.c \
-		    tools/md5.c \
-		    tools/sha1.c
+		    tools/hashtab.c 
 debugedit_CFLAGS = @LIBELF_CFLAGS@ @LIBDW_CFLAGS@ $(AM_CFLAGS)
 debugedit_LDADD = @LIBELF_LIBS@ @LIBDW_LIBS@
 
@@ -85,8 +83,6 @@ find-debuginfo.1: $(top_srcdir)/scripts/find-debuginfo.in configure.ac find-debu
 	esac
 
 noinst_HEADERS= tools/ansidecl.h \
-		tools/hashtab.h \
-		tools/md5.h \
-		tools/sha1.h
+		tools/hashtab.h
 
 EXTRA_DIST = README COPYING COPYING3 COPYING.LIB scripts/find-debuginfo.in
diff --git a/configure.ac b/configure.ac
index 79803dc8d197..7b842a4ddd25 100644
--- a/configure.ac
+++ b/configure.ac
@@ -75,6 +75,7 @@ AC_SYS_LARGEFILE
 PKG_PROG_PKG_CONFIG
 PKG_CHECK_MODULES([LIBELF], [libelf])
 PKG_CHECK_MODULES([LIBDW], [libdw])
+PKG_CHECK_MODULES([XXHASH], [libxxhash >= 0.8.1])
 
 # Checks for header files.
 AC_CHECK_HEADERS([fcntl.h inttypes.h limits.h malloc.h stddef.h stdint.h stdlib.h string.h unistd.h])
diff --git a/tests/debugedit.at b/tests/debugedit.at
index 4413704acc0b..68886b1f3d79 100644
--- a/tests/debugedit.at
+++ b/tests/debugedit.at
@@ -717,3 +717,43 @@ $CC $CFLAGS -gdwarf-5 -o main main.c
 AT_CHECK([[debugedit -l sources.list main]])
 AT_CHECK([[grep -q main.c sources.list]])
 AT_CLEANUP
+
+
+# ===
+# build-id recomputation
+# ===
+AT_SETUP([debugedit build-id recompute])
+AT_KEYWORDS([debuginfo] [debugedit] [build-id])
+
+# compile a test program and extract its linker-assigned build-id
+echo "int main () { }" > main.c
+$CC $CFLAGS -Wl,--build-id -o main main.c
+AT_CHECK([[$READELF -n main | grep Build.ID: | awk '{print $3}']], [0], [stdout], [ignore])
+bid="`cat stdout`"
+AT_CHECK([[expr "$bid" : '[0-9a-f]*']], [0], [ignore])
+
+# run debugedit to recompute build-id
+AT_CHECK([[debugedit -i -s deadbeef main]], [0], [stdout])
+bid2a="`cat stdout`"
+AT_CHECK([[expr "$bid2a" : '[0-9a-f]*']], [0], [ignore])
+AT_CHECK([[test "$bid" != "$bid2a"]])
+
+# check that debugedit's stdout matches readelf -n note
+AT_CHECK([[$READELF -n main | grep Build.ID: | awk '{print $3}']], [0], [stdout], [ignore])
+bid2b="`cat stdout`"
+AT_CHECK([[expr "$bid2b" : '[0-9a-f]*']], [0], [ignore])
+AT_CHECK([[test "$bid2a" == "$bid2b"]])
+
+# run debugedit to recompute build-id, check for idempotence
+AT_CHECK([[debugedit -i -s deadbeef main]], [0], [stdout])
+bid2c="`cat stdout`"
+AT_CHECK([[expr "$bid2c" : '[0-9a-f]*']], [0], [ignore])
+AT_CHECK([[test "$bid2a" == "$bid2c"]])
+
+# check that debugedit -i with different -s seed results in different valid build-id
+AT_CHECK([[debugedit -i -s zoofoo main]], [0], [stdout])
+bid3="`cat stdout`"
+AT_CHECK([[expr "$bid3" : '[0-9a-f]*']], [0], [ignore])
+AT_CHECK([[test "$bid3" != "$bid2a"]])
+
+AT_CLEANUP
diff --git a/tools/debugedit.c b/tools/debugedit.c
index 6bdb3f7f1d63..d31e8e4d2207 100644
--- a/tools/debugedit.c
+++ b/tools/debugedit.c
@@ -30,6 +30,7 @@
 #include <limits.h>
 #include <string.h>
 #include <stdlib.h>
+#include <stdio.h>
 #include <stdint.h>
 #include <inttypes.h>
 #include <unistd.h>
@@ -44,6 +45,9 @@
 #ifndef MAX
 #define MAX(m, n) ((m) < (n) ? (n) : (m))
 #endif
+#ifndef MIN
+#define MIN(m, n) ((m) > (n) ? (n) : (m))
+#endif
 
 
 /* Unfortunately strtab manipulation functions were only officially added
@@ -77,8 +81,8 @@ typedef struct Ebl_Strtab	Strtab;
 
 #include "tools/hashtab.h"
 
-#include "tools/md5.h"
-#include "tools/sha1.h"
+#define XXH_INLINE_ALL
+#include "xxhash.h"
 
 #define DW_TAG_partial_unit 0x3c
 #define DW_FORM_sec_offset 0x17
@@ -3423,10 +3427,10 @@ static void
 handle_build_id (DSO *dso, Elf_Data *build_id,
 		 size_t build_id_offset, size_t build_id_size)
 {
-  /* For now we only handle 16 byte (128 bits) with md5 or 20 bytes
-     (160 bits) with sha1.  */
-
-  if (build_id_size != 16 && build_id_size != 20)
+  /* Accept any build_id_size > 0.  Hashes will be truncated or padded
+     to the incoming note size, as debugedit cannot change their
+     size. */
+  if (build_id_size <= 0)
     {
       error (1, 0, "Cannot handle %zu-byte build ID", build_id_size);
     }
@@ -3436,25 +3440,24 @@ handle_build_id (DSO *dso, Elf_Data *build_id,
       || (! dirty_elf && build_id_seed == NULL))
     goto print;
 
-  /* Clear the old bits so they do not affect the new hash.  */
-  memset ((char *) build_id->d_buf + build_id_offset, 0, build_id_size);
-
-  struct md5_ctx md5_ctx;
-  struct sha1_ctx sha1_ctx;
+  /* Clear the bits about to be recomputed, so they do not affect the
+     new hash.  Extra bits left over from wider-than-128-bit hash are
+     preserved for extra entropy.  This computation should be
+     idempotent, so repeated rehashes (with the same seed) should
+     result in the same hash. */
+  XXH128_canonical_t result_canon;
+  memset ((char *) build_id->d_buf + build_id_offset, 0,
+          MIN (build_id_size, sizeof(result_canon)));
 
-  if (build_id_size == 16)
-    md5_init_ctx (&md5_ctx);
-  else
-    sha1_init_ctx (&sha1_ctx);
+  XXH3_state_t* state = XXH3_createState();
+  if (!state)
+    error (1, errno, "Failed to create xxhash state");
+  XXH3_128bits_reset (state);
 
   /* If a seed string was given use it to prime the hash.  */
   if (build_id_seed != NULL)
-    {
-      if (build_id_size == 16)
-	md5_process_bytes (build_id_seed, strlen (build_id_seed), &md5_ctx);
-      else
-	sha1_process_bytes (build_id_seed, strlen (build_id_seed), &sha1_ctx);
-    }
+    /* Another choice is XXH3_generateSecret. */
+    XXH3_128bits_update (state, build_id_seed, strlen (build_id_seed));
 
   /* Slurp the relevant header bits and section contents and feed them
      into the hash function.  The only bits we ignore are the offset
@@ -3493,10 +3496,7 @@ handle_build_id (DSO *dso, Elf_Data *build_id,
 	if (elf64_xlatetom (&x, &x, dso->ehdr.e_ident[EI_DATA]) == NULL)
 	  goto bad;
 
-	if (build_id_size == 16)
-	  md5_process_bytes (x.d_buf, x.d_size, &md5_ctx);
-	else
-	  sha1_process_bytes (x.d_buf, x.d_size, &sha1_ctx);
+        XXH3_128bits_update (state, x.d_buf, x.d_size);
       }
 
     x.d_type = ELF_T_SHDR;
@@ -3509,10 +3509,7 @@ handle_build_id (DSO *dso, Elf_Data *build_id,
 	  if (elf64_xlatetom (&x, &x, dso->ehdr.e_ident[EI_DATA]) == NULL)
 	    goto bad;
 
-	  if (build_id_size == 16)
-	    md5_process_bytes (x.d_buf, x.d_size, &md5_ctx);
-	  else
-	    sha1_process_bytes (x.d_buf, x.d_size, &sha1_ctx);
+          XXH3_128bits_update (state, x.d_buf, x.d_size);
 
 	  if (dso->shdr[i].sh_type != SHT_NOBITS)
 	    {
@@ -3520,26 +3517,17 @@ handle_build_id (DSO *dso, Elf_Data *build_id,
 	      if (d == NULL)
 		goto bad;
 
-	      if (build_id_size == 16)
-		md5_process_bytes (d->d_buf, d->d_size, &md5_ctx);
-	      else
-		sha1_process_bytes (d->d_buf, d->d_size, &sha1_ctx);
+              XXH3_128bits_update (state, d->d_buf, d->d_size);
 	    }
 	}
   }
 
-  /* Allocate the memory first to make sure alignment is correct. */
-  void *digest = malloc (build_id_size);
-  if (digest == NULL)
-    goto bad;
-
-  if (build_id_size == 16)
-    md5_finish_ctx (&md5_ctx, digest);
-  else
-    sha1_finish_ctx (&sha1_ctx, digest);
-
-  memcpy((unsigned char *)build_id->d_buf + build_id_offset, digest, build_id_size);
-  free(digest);
+  XXH128_hash_t result = XXH3_128bits_digest (state);
+  XXH3_freeState (state);
+  /* Use canonical-endianness output. */
+  XXH128_canonicalFromHash (&result_canon, result);
+  memcpy((unsigned char *)build_id->d_buf + build_id_offset, &result_canon,
+         MIN (build_id_size, sizeof(result_canon)));
 
   elf_flagdata (build_id, ELF_C_SET, ELF_F_DIRTY);
 
diff --git a/tools/md5.c b/tools/md5.c
deleted file mode 100644
index a8c8de22c210..000000000000
--- a/tools/md5.c
+++ /dev/null
@@ -1,440 +0,0 @@
-/* md5.c - Functions to compute MD5 message digest of files or memory blocks
-   according to the definition of MD5 in RFC 1321 from April 1992.
-   Copyright (C) 1995-2021 Free Software Foundation, Inc.
-
-   NOTE: This source is derived from an old version taken from the GNU C
-   Library (glibc).
-
-   This program is free software; you can redistribute it and/or modify it
-   under the terms of the GNU General Public License as published by the
-   Free Software Foundation; either version 2, or (at your option) any
-   later version.
-
-   This program is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-   GNU General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software Foundation,
-   Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.  */
-
-/* Written by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1995.  */
-
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#include <sys/types.h>
-
-#if STDC_HEADERS || defined _LIBC
-# include <stdlib.h>
-# include <string.h>
-#else
-# ifndef HAVE_MEMCPY
-#  define memcpy(d, s, n) bcopy ((s), (d), (n))
-# endif
-#endif
-
-#include "ansidecl.h"
-#include "md5.h"
-
-#ifdef _LIBC
-# include <endian.h>
-# if __BYTE_ORDER == __BIG_ENDIAN
-#  define WORDS_BIGENDIAN 1
-# endif
-#endif
-
-#ifdef WORDS_BIGENDIAN
-# define SWAP(n)							\
-    (((n) << 24) | (((n) & 0xff00) << 8) | (((n) >> 8) & 0xff00) | ((n) >> 24))
-#else
-# define SWAP(n) (n)
-#endif
-
-
-/* This array contains the bytes used to pad the buffer to the next
-   64-byte boundary.  (RFC 1321, 3.1: Step 1)  */
-static const unsigned char fillbuf[64] = { 0x80, 0 /* , 0, 0, ...  */ };
-
-
-/* Initialize structure containing state of computation.
-   (RFC 1321, 3.3: Step 3)  */
-void
-md5_init_ctx (struct md5_ctx *ctx)
-{
-  ctx->A = (md5_uint32) 0x67452301;
-  ctx->B = (md5_uint32) 0xefcdab89;
-  ctx->C = (md5_uint32) 0x98badcfe;
-  ctx->D = (md5_uint32) 0x10325476;
-
-  ctx->total[0] = ctx->total[1] = 0;
-  ctx->buflen = 0;
-}
-
-/* Put result from CTX in first 16 bytes following RESBUF.  The result
-   must be in little endian byte order.
-
-   IMPORTANT: RESBUF may not be aligned as strongly as MD5_UNIT32 so we
-   put things in a local (aligned) buffer first, then memcpy into RESBUF.  */
-void *
-md5_read_ctx (const struct md5_ctx *ctx, void *resbuf)
-{
-  md5_uint32 buffer[4];
-
-  buffer[0] = SWAP (ctx->A);
-  buffer[1] = SWAP (ctx->B);
-  buffer[2] = SWAP (ctx->C);
-  buffer[3] = SWAP (ctx->D);
-
-  memcpy (resbuf, buffer, 16);
-
-  return resbuf;
-}
-
-/* Process the remaining bytes in the internal buffer and the usual
-   prolog according to the standard and write the result to RESBUF.
-
-   IMPORTANT: On some systems it is required that RESBUF is correctly
-   aligned for a 32 bits value.  */
-void *
-md5_finish_ctx (struct md5_ctx *ctx, void *resbuf)
-{
-  /* Take yet unprocessed bytes into account.  */
-  md5_uint32 bytes = ctx->buflen;
-  md5_uint32 swap_bytes;
-  size_t pad;
-
-  /* Now count remaining bytes.  */
-  ctx->total[0] += bytes;
-  if (ctx->total[0] < bytes)
-    ++ctx->total[1];
-
-  pad = bytes >= 56 ? 64 + 56 - bytes : 56 - bytes;
-  memcpy (&ctx->buffer[bytes], fillbuf, pad);
-
-  /* Put the 64-bit file length in *bits* at the end of the buffer.
-     Use memcpy to avoid aliasing problems.  On most systems, this
-     will be optimized away to the same code.  */
-  swap_bytes = SWAP (ctx->total[0] << 3);
-  memcpy (&ctx->buffer[bytes + pad], &swap_bytes, sizeof (swap_bytes));
-  swap_bytes = SWAP ((ctx->total[1] << 3) | (ctx->total[0] >> 29));
-  memcpy (&ctx->buffer[bytes + pad + 4], &swap_bytes, sizeof (swap_bytes));
-
-  /* Process last bytes.  */
-  md5_process_block (ctx->buffer, bytes + pad + 8, ctx);
-
-  return md5_read_ctx (ctx, resbuf);
-}
-
-/* Compute MD5 message digest for bytes read from STREAM.  The
-   resulting message digest number will be written into the 16 bytes
-   beginning at RESBLOCK.  */
-int
-md5_stream (FILE *stream, void *resblock)
-{
-  /* Important: BLOCKSIZE must be a multiple of 64.  */
-#define BLOCKSIZE 4096
-  struct md5_ctx ctx;
-  char buffer[BLOCKSIZE + 72];
-  size_t sum;
-
-  /* Initialize the computation context.  */
-  md5_init_ctx (&ctx);
-
-  /* Iterate over full file contents.  */
-  while (1)
-    {
-      /* We read the file in blocks of BLOCKSIZE bytes.  One call of the
-	 computation function processes the whole buffer so that with the
-	 next round of the loop another block can be read.  */
-      size_t n;
-      sum = 0;
-
-      /* Read block.  Take care for partial reads.  */
-      do
-	{
-	  n = fread (buffer + sum, 1, BLOCKSIZE - sum, stream);
-
-	  sum += n;
-	}
-      while (sum < BLOCKSIZE && n != 0);
-      if (n == 0 && ferror (stream))
-        return 1;
-
-      /* If end of file is reached, end the loop.  */
-      if (n == 0)
-	break;
-
-      /* Process buffer with BLOCKSIZE bytes.  Note that
-			BLOCKSIZE % 64 == 0
-       */
-      md5_process_block (buffer, BLOCKSIZE, &ctx);
-    }
-
-  /* Add the last bytes if necessary.  */
-  if (sum > 0)
-    md5_process_bytes (buffer, sum, &ctx);
-
-  /* Construct result in desired memory.  */
-  md5_finish_ctx (&ctx, resblock);
-  return 0;
-}
-
-/* Compute MD5 message digest for LEN bytes beginning at BUFFER.  The
-   result is always in little endian byte order, so that a byte-wise
-   output yields to the wanted ASCII representation of the message
-   digest.  */
-void *
-md5_buffer (const char *buffer, size_t len, void *resblock)
-{
-  struct md5_ctx ctx;
-
-  /* Initialize the computation context.  */
-  md5_init_ctx (&ctx);
-
-  /* Process whole buffer but last len % 64 bytes.  */
-  md5_process_bytes (buffer, len, &ctx);
-
-  /* Put result in desired memory area.  */
-  return md5_finish_ctx (&ctx, resblock);
-}
-
-
-void
-md5_process_bytes (const void *buffer, size_t len, struct md5_ctx *ctx)
-{
-  /* When we already have some bits in our internal buffer concatenate
-     both inputs first.  */
-  if (ctx->buflen != 0)
-    {
-      size_t left_over = ctx->buflen;
-      size_t add = 128 - left_over > len ? len : 128 - left_over;
-
-      memcpy (&ctx->buffer[left_over], buffer, add);
-      ctx->buflen += add;
-
-      if (left_over + add > 64)
-	{
-	  md5_process_block (ctx->buffer, (left_over + add) & ~63, ctx);
-	  /* The regions in the following copy operation cannot overlap.  */
-	  memcpy (ctx->buffer, &ctx->buffer[(left_over + add) & ~63],
-		  (left_over + add) & 63);
-	  ctx->buflen = (left_over + add) & 63;
-	}
-
-      buffer = (const void *) ((const char *) buffer + add);
-      len -= add;
-    }
-
-  /* Process available complete blocks.  */
-  if (len > 64)
-    {
-#if !_STRING_ARCH_unaligned || defined UBSAN_BOOTSTRAP
-/* To check alignment gcc has an appropriate operator.  Other
-   compilers don't.  */
-# if __GNUC__ >= 2
-#  define UNALIGNED_P(p) (((md5_uintptr) p) % __alignof__ (md5_uint32) != 0)
-# else
-#  define UNALIGNED_P(p) (((md5_uintptr) p) % sizeof (md5_uint32) != 0)
-# endif
-      if (UNALIGNED_P (buffer))
-        while (len > 64)
-          {
-	    memcpy (ctx->buffer, buffer, 64);
-            md5_process_block (ctx->buffer, 64, ctx);
-            buffer = (const char *) buffer + 64;
-            len -= 64;
-          }
-      else
-#endif
-	{
-	  md5_process_block (buffer, len & ~63, ctx);
-	  buffer = (const void *) ((const char *) buffer + (len & ~63));
-	  len &= 63;
-	}
-    }
-
-  /* Move remaining bytes in internal buffer.  */
-  if (len > 0)
-    {
-      memcpy (ctx->buffer, buffer, len);
-      ctx->buflen = len;
-    }
-}
-
-
-/* These are the four functions used in the four steps of the MD5 algorithm
-   and defined in the RFC 1321.  The first function is a little bit optimized
-   (as found in Colin Plumbs public domain implementation).  */
-/* #define FF(b, c, d) ((b & c) | (~b & d)) */
-#define FF(b, c, d) (d ^ (b & (c ^ d)))
-#define FG(b, c, d) FF (d, b, c)
-#define FH(b, c, d) (b ^ c ^ d)
-#define FI(b, c, d) (c ^ (b | ~d))
-
-/* Process LEN bytes of BUFFER, accumulating context into CTX.
-   It is assumed that LEN % 64 == 0.  */
-
-void
-md5_process_block (const void *buffer, size_t len, struct md5_ctx *ctx)
-{
-  md5_uint32 correct_words[16];
-  const md5_uint32 *words = (const md5_uint32 *) buffer;
-  size_t nwords = len / sizeof (md5_uint32);
-  const md5_uint32 *endp = words + nwords;
-  md5_uint32 A = ctx->A;
-  md5_uint32 B = ctx->B;
-  md5_uint32 C = ctx->C;
-  md5_uint32 D = ctx->D;
-
-  /* First increment the byte count.  RFC 1321 specifies the possible
-     length of the file up to 2^64 bits.  Here we only compute the
-     number of bytes.  Do a double word increment.  */
-  ctx->total[0] += len;
-  ctx->total[1] += ((len >> 31) >> 1) + (ctx->total[0] < len);
-
-  /* Process all bytes in the buffer with 64 bytes in each round of
-     the loop.  */
-  while (words < endp)
-    {
-      md5_uint32 *cwp = correct_words;
-      md5_uint32 A_save = A;
-      md5_uint32 B_save = B;
-      md5_uint32 C_save = C;
-      md5_uint32 D_save = D;
-
-      /* First round: using the given function, the context and a constant
-	 the next context is computed.  Because the algorithms processing
-	 unit is a 32-bit word and it is determined to work on words in
-	 little endian byte order we perhaps have to change the byte order
-	 before the computation.  To reduce the work for the next steps
-	 we store the swapped words in the array CORRECT_WORDS.  */
-
-#define OP(a, b, c, d, s, T)						\
-      do								\
-        {								\
-	  a += FF (b, c, d) + (*cwp++ = SWAP (*words)) + T;		\
-	  ++words;							\
-	  CYCLIC (a, s);						\
-	  a += b;							\
-        }								\
-      while (0)
-
-      /* It is unfortunate that C does not provide an operator for
-	 cyclic rotation.  Hope the C compiler is smart enough.  */
-#define CYCLIC(w, s) (w = (w << s) | (w >> (32 - s)))
-
-      /* Before we start, one word to the strange constants.
-	 They are defined in RFC 1321 as
-
-	 T[i] = (int) (4294967296.0 * fabs (sin (i))), i=1..64
-       */
-
-      /* Round 1.  */
-      OP (A, B, C, D,  7, (md5_uint32) 0xd76aa478);
-      OP (D, A, B, C, 12, (md5_uint32) 0xe8c7b756);
-      OP (C, D, A, B, 17, (md5_uint32) 0x242070db);
-      OP (B, C, D, A, 22, (md5_uint32) 0xc1bdceee);
-      OP (A, B, C, D,  7, (md5_uint32) 0xf57c0faf);
-      OP (D, A, B, C, 12, (md5_uint32) 0x4787c62a);
-      OP (C, D, A, B, 17, (md5_uint32) 0xa8304613);
-      OP (B, C, D, A, 22, (md5_uint32) 0xfd469501);
-      OP (A, B, C, D,  7, (md5_uint32) 0x698098d8);
-      OP (D, A, B, C, 12, (md5_uint32) 0x8b44f7af);
-      OP (C, D, A, B, 17, (md5_uint32) 0xffff5bb1);
-      OP (B, C, D, A, 22, (md5_uint32) 0x895cd7be);
-      OP (A, B, C, D,  7, (md5_uint32) 0x6b901122);
-      OP (D, A, B, C, 12, (md5_uint32) 0xfd987193);
-      OP (C, D, A, B, 17, (md5_uint32) 0xa679438e);
-      OP (B, C, D, A, 22, (md5_uint32) 0x49b40821);
-
-      /* For the second to fourth round we have the possibly swapped words
-	 in CORRECT_WORDS.  Redefine the macro to take an additional first
-	 argument specifying the function to use.  */
-#undef OP
-#define OP(a, b, c, d, k, s, T)						\
-      do 								\
-	{								\
-	  a += FX (b, c, d) + correct_words[k] + T;			\
-	  CYCLIC (a, s);						\
-	  a += b;							\
-	}								\
-      while (0)
-
-#define FX(b, c, d) FG (b, c, d)
-
-      /* Round 2.  */
-      OP (A, B, C, D,  1,  5, (md5_uint32) 0xf61e2562);
-      OP (D, A, B, C,  6,  9, (md5_uint32) 0xc040b340);
-      OP (C, D, A, B, 11, 14, (md5_uint32) 0x265e5a51);
-      OP (B, C, D, A,  0, 20, (md5_uint32) 0xe9b6c7aa);
-      OP (A, B, C, D,  5,  5, (md5_uint32) 0xd62f105d);
-      OP (D, A, B, C, 10,  9, (md5_uint32) 0x02441453);
-      OP (C, D, A, B, 15, 14, (md5_uint32) 0xd8a1e681);
-      OP (B, C, D, A,  4, 20, (md5_uint32) 0xe7d3fbc8);
-      OP (A, B, C, D,  9,  5, (md5_uint32) 0x21e1cde6);
-      OP (D, A, B, C, 14,  9, (md5_uint32) 0xc33707d6);
-      OP (C, D, A, B,  3, 14, (md5_uint32) 0xf4d50d87);
-      OP (B, C, D, A,  8, 20, (md5_uint32) 0x455a14ed);
-      OP (A, B, C, D, 13,  5, (md5_uint32) 0xa9e3e905);
-      OP (D, A, B, C,  2,  9, (md5_uint32) 0xfcefa3f8);
-      OP (C, D, A, B,  7, 14, (md5_uint32) 0x676f02d9);
-      OP (B, C, D, A, 12, 20, (md5_uint32) 0x8d2a4c8a);
-
-#undef FX
-#define FX(b, c, d) FH (b, c, d)
-
-      /* Round 3.  */
-      OP (A, B, C, D,  5,  4, (md5_uint32) 0xfffa3942);
-      OP (D, A, B, C,  8, 11, (md5_uint32) 0x8771f681);
-      OP (C, D, A, B, 11, 16, (md5_uint32) 0x6d9d6122);
-      OP (B, C, D, A, 14, 23, (md5_uint32) 0xfde5380c);
-      OP (A, B, C, D,  1,  4, (md5_uint32) 0xa4beea44);
-      OP (D, A, B, C,  4, 11, (md5_uint32) 0x4bdecfa9);
-      OP (C, D, A, B,  7, 16, (md5_uint32) 0xf6bb4b60);
-      OP (B, C, D, A, 10, 23, (md5_uint32) 0xbebfbc70);
-      OP (A, B, C, D, 13,  4, (md5_uint32) 0x289b7ec6);
-      OP (D, A, B, C,  0, 11, (md5_uint32) 0xeaa127fa);
-      OP (C, D, A, B,  3, 16, (md5_uint32) 0xd4ef3085);
-      OP (B, C, D, A,  6, 23, (md5_uint32) 0x04881d05);
-      OP (A, B, C, D,  9,  4, (md5_uint32) 0xd9d4d039);
-      OP (D, A, B, C, 12, 11, (md5_uint32) 0xe6db99e5);
-      OP (C, D, A, B, 15, 16, (md5_uint32) 0x1fa27cf8);
-      OP (B, C, D, A,  2, 23, (md5_uint32) 0xc4ac5665);
-
-#undef FX
-#define FX(b, c, d) FI (b, c, d)
-
-      /* Round 4.  */
-      OP (A, B, C, D,  0,  6, (md5_uint32) 0xf4292244);
-      OP (D, A, B, C,  7, 10, (md5_uint32) 0x432aff97);
-      OP (C, D, A, B, 14, 15, (md5_uint32) 0xab9423a7);
-      OP (B, C, D, A,  5, 21, (md5_uint32) 0xfc93a039);
-      OP (A, B, C, D, 12,  6, (md5_uint32) 0x655b59c3);
-      OP (D, A, B, C,  3, 10, (md5_uint32) 0x8f0ccc92);
-      OP (C, D, A, B, 10, 15, (md5_uint32) 0xffeff47d);
-      OP (B, C, D, A,  1, 21, (md5_uint32) 0x85845dd1);
-      OP (A, B, C, D,  8,  6, (md5_uint32) 0x6fa87e4f);
-      OP (D, A, B, C, 15, 10, (md5_uint32) 0xfe2ce6e0);
-      OP (C, D, A, B,  6, 15, (md5_uint32) 0xa3014314);
-      OP (B, C, D, A, 13, 21, (md5_uint32) 0x4e0811a1);
-      OP (A, B, C, D,  4,  6, (md5_uint32) 0xf7537e82);
-      OP (D, A, B, C, 11, 10, (md5_uint32) 0xbd3af235);
-      OP (C, D, A, B,  2, 15, (md5_uint32) 0x2ad7d2bb);
-      OP (B, C, D, A,  9, 21, (md5_uint32) 0xeb86d391);
-
-      /* Add the starting values of the context.  */
-      A += A_save;
-      B += B_save;
-      C += C_save;
-      D += D_save;
-    }
-
-  /* Put checksum in context given as argument.  */
-  ctx->A = A;
-  ctx->B = B;
-  ctx->C = C;
-  ctx->D = D;
-}
diff --git a/tools/md5.h b/tools/md5.h
deleted file mode 100644
index 03f7d29afc75..000000000000
--- a/tools/md5.h
+++ /dev/null
@@ -1,154 +0,0 @@
-/* md5.h - Declaration of functions and data types used for MD5 sum
-   computing library functions.
-   Copyright (C) 1995-2021 Free Software Foundation, Inc.
-   NOTE: The canonical source of this file is maintained with the GNU C
-   Library.  Bugs can be reported to bug-glibc@prep.ai.mit.edu.
-
-   This program is free software; you can redistribute it and/or modify it
-   under the terms of the GNU General Public License as published by the
-   Free Software Foundation; either version 2, or (at your option) any
-   later version.
-
-   This program is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-   GNU General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software Foundation,
-   Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.  */
-
-#ifndef _MD5_H
-#define _MD5_H 1
-
-#include <stdio.h>
-
-#if defined HAVE_LIMITS_H || _LIBC
-# include <limits.h>
-#endif
-
-#include "ansidecl.h"
-
-/* The following contortions are an attempt to use the C preprocessor
-   to determine an unsigned integral type that is 32 bits wide.  An
-   alternative approach is to use autoconf's AC_CHECK_SIZEOF macro, but
-   doing that would require that the configure script compile and *run*
-   the resulting executable.  Locally running cross-compiled executables
-   is usually not possible.  */
-
-#ifdef _LIBC
-# include <sys/types.h>
-typedef u_int32_t md5_uint32;
-typedef uintptr_t md5_uintptr;
-#elif defined (HAVE_SYS_TYPES_H) && defined (HAVE_STDINT_H)
-#include <stdint.h>
-#include <sys/types.h>
-typedef uint32_t md5_uint32;
-typedef uintptr_t md5_uintptr;
-#else
-#  define INT_MAX_32_BITS 2147483647
-
-/* If UINT_MAX isn't defined, assume it's a 32-bit type.
-   This should be valid for all systems GNU cares about because
-   that doesn't include 16-bit systems, and only modern systems
-   (that certainly have <limits.h>) have 64+-bit integral types.  */
-
-# ifndef INT_MAX
-#  define INT_MAX INT_MAX_32_BITS
-# endif
-
-# if INT_MAX == INT_MAX_32_BITS
-   typedef unsigned int md5_uint32;
-# else
-#  if SHRT_MAX == INT_MAX_32_BITS
-    typedef unsigned short md5_uint32;
-#  else
-#   if LONG_MAX == INT_MAX_32_BITS
-     typedef unsigned long md5_uint32;
-#   else
-     /* The following line is intended to evoke an error.
-        Using #error is not portable enough.  */
-     "Cannot determine unsigned 32-bit data type."
-#   endif
-#  endif
-# endif
-/* We have to make a guess about the integer type equivalent in size
-   to pointers which should always be correct.  */
-typedef unsigned long int md5_uintptr;
-#endif
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/* Structure to save state of computation between the single steps.  */
-struct md5_ctx
-{
-  md5_uint32 A;
-  md5_uint32 B;
-  md5_uint32 C;
-  md5_uint32 D;
-
-  md5_uint32 total[2];
-  md5_uint32 buflen;
-  char buffer[128] ATTRIBUTE_ALIGNED_ALIGNOF(md5_uint32);
-};
-
-/*
- * The following three functions are build up the low level used in
- * the functions `md5_stream' and `md5_buffer'.
- */
-
-/* Initialize structure containing state of computation.
-   (RFC 1321, 3.3: Step 3)  */
-extern void md5_init_ctx (struct md5_ctx *ctx);
-
-/* Starting with the result of former calls of this function (or the
-   initialization function update the context for the next LEN bytes
-   starting at BUFFER.
-   It is necessary that LEN is a multiple of 64!!! */
-extern void md5_process_block (const void *buffer, size_t len,
-                               struct md5_ctx *ctx);
-
-/* Starting with the result of former calls of this function (or the
-   initialization function update the context for the next LEN bytes
-   starting at BUFFER.
-   It is NOT required that LEN is a multiple of 64.  */
-extern void md5_process_bytes (const void *buffer, size_t len,
-                               struct md5_ctx *ctx);
-
-/* Process the remaining bytes in the buffer and put result from CTX
-   in first 16 bytes following RESBUF.  The result is always in little
-   endian byte order, so that a byte-wise output yields to the wanted
-   ASCII representation of the message digest.
-
-   IMPORTANT: On some systems it is required that RESBUF is correctly
-   aligned for a 32 bits value.  */
-extern void *md5_finish_ctx (struct md5_ctx *ctx, void *resbuf);
-
-
-/* Put result from CTX in first 16 bytes following RESBUF.  The result is
-   always in little endian byte order, so that a byte-wise output yields
-   to the wanted ASCII representation of the message digest.
-
-   IMPORTANT: On some systems it is required that RESBUF is correctly
-   aligned for a 32 bits value.  */
-extern void *md5_read_ctx (const struct md5_ctx *ctx, void *resbuf);
-
-
-/* Compute MD5 message digest for bytes read from STREAM.  The
-   resulting message digest number will be written into the 16 bytes
-   beginning at RESBLOCK.  */
-extern int md5_stream (FILE *stream, void *resblock);
-
-/* Compute MD5 message digest for LEN bytes beginning at BUFFER.  The
-   result is always in little endian byte order, so that a byte-wise
-   output yields to the wanted ASCII representation of the message
-   digest.  */
-extern void *md5_buffer (const char *buffer, size_t len, void *resblock);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/tools/sha1.c b/tools/sha1.c
deleted file mode 100644
index 7d15d48d11dd..000000000000
--- a/tools/sha1.c
+++ /dev/null
@@ -1,414 +0,0 @@
-/* sha1.c - Functions to compute SHA1 message digest of files or
-   memory blocks according to the NIST specification FIPS-180-1.
-
-   Copyright (C) 2000-2021 Free Software Foundation, Inc.
-
-   This program is free software; you can redistribute it and/or modify it
-   under the terms of the GNU General Public License as published by the
-   Free Software Foundation; either version 2, or (at your option) any
-   later version.
-
-   This program is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-   GNU General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software Foundation,
-   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
-
-/* Written by Scott G. Miller
-   Credits:
-      Robert Klep <robert@ilse.nl>  -- Expansion function fix
-*/
-
-#include <config.h>
-
-#include "sha1.h"
-
-#include <stddef.h>
-#include <string.h>
-
-#if USE_UNLOCKED_IO
-# include "unlocked-io.h"
-#endif
-
-#ifdef WORDS_BIGENDIAN
-# define SWAP(n) (n)
-#else
-# define SWAP(n) \
-    (((n) << 24) | (((n) & 0xff00) << 8) | (((n) >> 8) & 0xff00) | ((n) >> 24))
-#endif
-
-#define BLOCKSIZE 4096
-#if BLOCKSIZE % 64 != 0
-# error "invalid BLOCKSIZE"
-#endif
-
-/* This array contains the bytes used to pad the buffer to the next
-   64-byte boundary.  (RFC 1321, 3.1: Step 1)  */
-static const unsigned char fillbuf[64] = { 0x80, 0 /* , 0, 0, ...  */ };
-
-
-/* Take a pointer to a 160 bit block of data (five 32 bit ints) and
-   initialize it to the start constants of the SHA1 algorithm.  This
-   must be called before using hash in the call to sha1_hash.  */
-void
-sha1_init_ctx (struct sha1_ctx *ctx)
-{
-  ctx->A = 0x67452301;
-  ctx->B = 0xefcdab89;
-  ctx->C = 0x98badcfe;
-  ctx->D = 0x10325476;
-  ctx->E = 0xc3d2e1f0;
-
-  ctx->total[0] = ctx->total[1] = 0;
-  ctx->buflen = 0;
-}
-
-/* Put result from CTX in first 20 bytes following RESBUF.  The result
-   must be in little endian byte order.
-
-   IMPORTANT: On some systems it is required that RESBUF is correctly
-   aligned for a 32-bit value.  */
-void *
-sha1_read_ctx (const struct sha1_ctx *ctx, void *resbuf)
-{
-  ((sha1_uint32 *) resbuf)[0] = SWAP (ctx->A);
-  ((sha1_uint32 *) resbuf)[1] = SWAP (ctx->B);
-  ((sha1_uint32 *) resbuf)[2] = SWAP (ctx->C);
-  ((sha1_uint32 *) resbuf)[3] = SWAP (ctx->D);
-  ((sha1_uint32 *) resbuf)[4] = SWAP (ctx->E);
-
-  return resbuf;
-}
-
-/* Process the remaining bytes in the internal buffer and the usual
-   prolog according to the standard and write the result to RESBUF.
-
-   IMPORTANT: On some systems it is required that RESBUF is correctly
-   aligned for a 32-bit value.  */
-void *
-sha1_finish_ctx (struct sha1_ctx *ctx, void *resbuf)
-{
-  /* Take yet unprocessed bytes into account.  */
-  sha1_uint32 bytes = ctx->buflen;
-  size_t size = (bytes < 56) ? 64 / 4 : 64 * 2 / 4;
-
-  /* Now count remaining bytes.  */
-  ctx->total[0] += bytes;
-  if (ctx->total[0] < bytes)
-    ++ctx->total[1];
-
-  /* Put the 64-bit file length in *bits* at the end of the buffer.  */
-  ctx->buffer[size - 2] = SWAP ((ctx->total[1] << 3) | (ctx->total[0] >> 29));
-  ctx->buffer[size - 1] = SWAP (ctx->total[0] << 3);
-
-  memcpy (&((char *) ctx->buffer)[bytes], fillbuf, (size - 2) * 4 - bytes);
-
-  /* Process last bytes.  */
-  sha1_process_block (ctx->buffer, size * 4, ctx);
-
-  return sha1_read_ctx (ctx, resbuf);
-}
-
-/* Compute SHA1 message digest for bytes read from STREAM.  The
-   resulting message digest number will be written into the 16 bytes
-   beginning at RESBLOCK.  */
-int
-sha1_stream (FILE *stream, void *resblock)
-{
-  struct sha1_ctx ctx;
-  char buffer[BLOCKSIZE + 72];
-  size_t sum;
-
-  /* Initialize the computation context.  */
-  sha1_init_ctx (&ctx);
-
-  /* Iterate over full file contents.  */
-  while (1)
-    {
-      /* We read the file in blocks of BLOCKSIZE bytes.  One call of the
-	 computation function processes the whole buffer so that with the
-	 next round of the loop another block can be read.  */
-      size_t n;
-      sum = 0;
-
-      /* Read block.  Take care for partial reads.  */
-      while (1)
-	{
-	  n = fread (buffer + sum, 1, BLOCKSIZE - sum, stream);
-
-	  sum += n;
-
-	  if (sum == BLOCKSIZE)
-	    break;
-
-	  if (n == 0)
-	    {
-	      /* Check for the error flag IFF N == 0, so that we don't
-		 exit the loop after a partial read due to e.g., EAGAIN
-		 or EWOULDBLOCK.  */
-	      if (ferror (stream))
-		return 1;
-	      goto process_partial_block;
-	    }
-
-	  /* We've read at least one byte, so ignore errors.  But always
-	     check for EOF, since feof may be true even though N > 0.
-	     Otherwise, we could end up calling fread after EOF.  */
-	  if (feof (stream))
-	    goto process_partial_block;
-	}
-
-      /* Process buffer with BLOCKSIZE bytes.  Note that
-			BLOCKSIZE % 64 == 0
-       */
-      sha1_process_block (buffer, BLOCKSIZE, &ctx);
-    }
-
- process_partial_block:;
-
-  /* Process any remaining bytes.  */
-  if (sum > 0)
-    sha1_process_bytes (buffer, sum, &ctx);
-
-  /* Construct result in desired memory.  */
-  sha1_finish_ctx (&ctx, resblock);
-  return 0;
-}
-
-/* Compute SHA1 message digest for LEN bytes beginning at BUFFER.  The
-   result is always in little endian byte order, so that a byte-wise
-   output yields to the wanted ASCII representation of the message
-   digest.  */
-void *
-sha1_buffer (const char *buffer, size_t len, void *resblock)
-{
-  struct sha1_ctx ctx;
-
-  /* Initialize the computation context.  */
-  sha1_init_ctx (&ctx);
-
-  /* Process whole buffer but last len % 64 bytes.  */
-  sha1_process_bytes (buffer, len, &ctx);
-
-  /* Put result in desired memory area.  */
-  return sha1_finish_ctx (&ctx, resblock);
-}
-
-void
-sha1_process_bytes (const void *buffer, size_t len, struct sha1_ctx *ctx)
-{
-  /* When we already have some bits in our internal buffer concatenate
-     both inputs first.  */
-  if (ctx->buflen != 0)
-    {
-      size_t left_over = ctx->buflen;
-      size_t add = 128 - left_over > len ? len : 128 - left_over;
-
-      memcpy (&((char *) ctx->buffer)[left_over], buffer, add);
-      ctx->buflen += add;
-
-      if (ctx->buflen > 64)
-	{
-	  sha1_process_block (ctx->buffer, ctx->buflen & ~63, ctx);
-
-	  ctx->buflen &= 63;
-	  /* The regions in the following copy operation cannot overlap.  */
-	  memcpy (ctx->buffer,
-		  &((char *) ctx->buffer)[(left_over + add) & ~63],
-		  ctx->buflen);
-	}
-
-      buffer = (const char *) buffer + add;
-      len -= add;
-    }
-
-  /* Process available complete blocks.  */
-  if (len >= 64)
-    {
-#if !_STRING_ARCH_unaligned
-# define alignof(type) offsetof (struct { char c; type x; }, x)
-# define UNALIGNED_P(p) (((size_t) p) % alignof (sha1_uint32) != 0)
-      if (UNALIGNED_P (buffer))
-	while (len > 64)
-	  {
-	    sha1_process_block (memcpy (ctx->buffer, buffer, 64), 64, ctx);
-	    buffer = (const char *) buffer + 64;
-	    len -= 64;
-	  }
-      else
-#endif
-	{
-	  sha1_process_block (buffer, len & ~63, ctx);
-	  buffer = (const char *) buffer + (len & ~63);
-	  len &= 63;
-	}
-    }
-
-  /* Move remaining bytes in internal buffer.  */
-  if (len > 0)
-    {
-      size_t left_over = ctx->buflen;
-
-      memcpy (&((char *) ctx->buffer)[left_over], buffer, len);
-      left_over += len;
-      if (left_over >= 64)
-	{
-	  sha1_process_block (ctx->buffer, 64, ctx);
-	  left_over -= 64;
-	  memmove (ctx->buffer, &ctx->buffer[16], left_over);
-	}
-      ctx->buflen = left_over;
-    }
-}
-
-/* --- Code below is the primary difference between md5.c and sha1.c --- */
-
-/* SHA1 round constants */
-#define K1 0x5a827999
-#define K2 0x6ed9eba1
-#define K3 0x8f1bbcdc
-#define K4 0xca62c1d6
-
-/* Round functions.  Note that F2 is the same as F4.  */
-#define F1(B,C,D) ( D ^ ( B & ( C ^ D ) ) )
-#define F2(B,C,D) (B ^ C ^ D)
-#define F3(B,C,D) ( ( B & C ) | ( D & ( B | C ) ) )
-#define F4(B,C,D) (B ^ C ^ D)
-
-/* Process LEN bytes of BUFFER, accumulating context into CTX.
-   It is assumed that LEN % 64 == 0.
-   Most of this code comes from GnuPG's cipher/sha1.c.  */
-
-void
-sha1_process_block (const void *buffer, size_t len, struct sha1_ctx *ctx)
-{
-  const sha1_uint32 *words = (const sha1_uint32*) buffer;
-  size_t nwords = len / sizeof (sha1_uint32);
-  const sha1_uint32 *endp = words + nwords;
-  sha1_uint32 x[16];
-  sha1_uint32 a = ctx->A;
-  sha1_uint32 b = ctx->B;
-  sha1_uint32 c = ctx->C;
-  sha1_uint32 d = ctx->D;
-  sha1_uint32 e = ctx->E;
-
-  /* First increment the byte count.  RFC 1321 specifies the possible
-     length of the file up to 2^64 bits.  Here we only compute the
-     number of bytes.  Do a double word increment.  */
-  ctx->total[0] += len;
-  ctx->total[1] += ((len >> 31) >> 1) + (ctx->total[0] < len);
-
-#define rol(x, n) (((x) << (n)) | ((sha1_uint32) (x) >> (32 - (n))))
-
-#define M(I) ( tm =   x[I&0x0f] ^ x[(I-14)&0x0f] \
-		    ^ x[(I-8)&0x0f] ^ x[(I-3)&0x0f] \
-	       , (x[I&0x0f] = rol(tm, 1)) )
-
-#define R(A,B,C,D,E,F,K,M)  do { E += rol( A, 5 )     \
-				      + F( B, C, D )  \
-				      + K	      \
-				      + M;	      \
-				 B = rol( B, 30 );    \
-			       } while(0)
-
-  while (words < endp)
-    {
-      sha1_uint32 tm;
-      int t;
-      for (t = 0; t < 16; t++)
-	{
-	  x[t] = SWAP (*words);
-	  words++;
-	}
-
-      R( a, b, c, d, e, F1, K1, x[ 0] );
-      R( e, a, b, c, d, F1, K1, x[ 1] );
-      R( d, e, a, b, c, F1, K1, x[ 2] );
-      R( c, d, e, a, b, F1, K1, x[ 3] );
-      R( b, c, d, e, a, F1, K1, x[ 4] );
-      R( a, b, c, d, e, F1, K1, x[ 5] );
-      R( e, a, b, c, d, F1, K1, x[ 6] );
-      R( d, e, a, b, c, F1, K1, x[ 7] );
-      R( c, d, e, a, b, F1, K1, x[ 8] );
-      R( b, c, d, e, a, F1, K1, x[ 9] );
-      R( a, b, c, d, e, F1, K1, x[10] );
-      R( e, a, b, c, d, F1, K1, x[11] );
-      R( d, e, a, b, c, F1, K1, x[12] );
-      R( c, d, e, a, b, F1, K1, x[13] );
-      R( b, c, d, e, a, F1, K1, x[14] );
-      R( a, b, c, d, e, F1, K1, x[15] );
-      R( e, a, b, c, d, F1, K1, M(16) );
-      R( d, e, a, b, c, F1, K1, M(17) );
-      R( c, d, e, a, b, F1, K1, M(18) );
-      R( b, c, d, e, a, F1, K1, M(19) );
-      R( a, b, c, d, e, F2, K2, M(20) );
-      R( e, a, b, c, d, F2, K2, M(21) );
-      R( d, e, a, b, c, F2, K2, M(22) );
-      R( c, d, e, a, b, F2, K2, M(23) );
-      R( b, c, d, e, a, F2, K2, M(24) );
-      R( a, b, c, d, e, F2, K2, M(25) );
-      R( e, a, b, c, d, F2, K2, M(26) );
-      R( d, e, a, b, c, F2, K2, M(27) );
-      R( c, d, e, a, b, F2, K2, M(28) );
-      R( b, c, d, e, a, F2, K2, M(29) );
-      R( a, b, c, d, e, F2, K2, M(30) );
-      R( e, a, b, c, d, F2, K2, M(31) );
-      R( d, e, a, b, c, F2, K2, M(32) );
-      R( c, d, e, a, b, F2, K2, M(33) );
-      R( b, c, d, e, a, F2, K2, M(34) );
-      R( a, b, c, d, e, F2, K2, M(35) );
-      R( e, a, b, c, d, F2, K2, M(36) );
-      R( d, e, a, b, c, F2, K2, M(37) );
-      R( c, d, e, a, b, F2, K2, M(38) );
-      R( b, c, d, e, a, F2, K2, M(39) );
-      R( a, b, c, d, e, F3, K3, M(40) );
-      R( e, a, b, c, d, F3, K3, M(41) );
-      R( d, e, a, b, c, F3, K3, M(42) );
-      R( c, d, e, a, b, F3, K3, M(43) );
-      R( b, c, d, e, a, F3, K3, M(44) );
-      R( a, b, c, d, e, F3, K3, M(45) );
-      R( e, a, b, c, d, F3, K3, M(46) );
-      R( d, e, a, b, c, F3, K3, M(47) );
-      R( c, d, e, a, b, F3, K3, M(48) );
-      R( b, c, d, e, a, F3, K3, M(49) );
-      R( a, b, c, d, e, F3, K3, M(50) );
-      R( e, a, b, c, d, F3, K3, M(51) );
-      R( d, e, a, b, c, F3, K3, M(52) );
-      R( c, d, e, a, b, F3, K3, M(53) );
-      R( b, c, d, e, a, F3, K3, M(54) );
-      R( a, b, c, d, e, F3, K3, M(55) );
-      R( e, a, b, c, d, F3, K3, M(56) );
-      R( d, e, a, b, c, F3, K3, M(57) );
-      R( c, d, e, a, b, F3, K3, M(58) );
-      R( b, c, d, e, a, F3, K3, M(59) );
-      R( a, b, c, d, e, F4, K4, M(60) );
-      R( e, a, b, c, d, F4, K4, M(61) );
-      R( d, e, a, b, c, F4, K4, M(62) );
-      R( c, d, e, a, b, F4, K4, M(63) );
-      R( b, c, d, e, a, F4, K4, M(64) );
-      R( a, b, c, d, e, F4, K4, M(65) );
-      R( e, a, b, c, d, F4, K4, M(66) );
-      R( d, e, a, b, c, F4, K4, M(67) );
-      R( c, d, e, a, b, F4, K4, M(68) );
-      R( b, c, d, e, a, F4, K4, M(69) );
-      R( a, b, c, d, e, F4, K4, M(70) );
-      R( e, a, b, c, d, F4, K4, M(71) );
-      R( d, e, a, b, c, F4, K4, M(72) );
-      R( c, d, e, a, b, F4, K4, M(73) );
-      R( b, c, d, e, a, F4, K4, M(74) );
-      R( a, b, c, d, e, F4, K4, M(75) );
-      R( e, a, b, c, d, F4, K4, M(76) );
-      R( d, e, a, b, c, F4, K4, M(77) );
-      R( c, d, e, a, b, F4, K4, M(78) );
-      R( b, c, d, e, a, F4, K4, M(79) );
-
-      a = ctx->A += a;
-      b = ctx->B += b;
-      c = ctx->C += c;
-      d = ctx->D += d;
-      e = ctx->E += e;
-    }
-}
diff --git a/tools/sha1.h b/tools/sha1.h
deleted file mode 100644
index ebeda4497f75..000000000000
--- a/tools/sha1.h
+++ /dev/null
@@ -1,145 +0,0 @@
-/* Declarations of functions and data types used for SHA1 sum
-   library functions.
-   Copyright (C) 2000-2021 Free Software Foundation, Inc.
-
-   This program is free software; you can redistribute it and/or modify it
-   under the terms of the GNU General Public License as published by the
-   Free Software Foundation; either version 3, or (at your option) any
-   later version.
-
-   This program is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-   GNU General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software Foundation,
-   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
-
-#ifndef SHA1_H
-# define SHA1_H 1
-
-#include <stdio.h>
-
-#if defined HAVE_LIMITS_H || _LIBC
-# include <limits.h>
-#endif
-
-#include "ansidecl.h"
-
-/* The following contortions are an attempt to use the C preprocessor
-   to determine an unsigned integral type that is 32 bits wide.  An
-   alternative approach is to use autoconf's AC_CHECK_SIZEOF macro, but
-   doing that would require that the configure script compile and *run*
-   the resulting executable.  Locally running cross-compiled executables
-   is usually not possible.  */
-
-#ifdef _LIBC
-# include <sys/types.h>
-typedef u_int32_t sha1_uint32;
-typedef uintptr_t sha1_uintptr;
-#elif defined (HAVE_SYS_TYPES_H) && defined (HAVE_STDINT_H)
-#include <stdint.h>
-#include <sys/types.h>
-typedef uint32_t sha1_uint32;
-typedef uintptr_t sha1_uintptr;
-#else
-#  define INT_MAX_32_BITS 2147483647
-
-/* If UINT_MAX isn't defined, assume it's a 32-bit type.
-   This should be valid for all systems GNU cares about because
-   that doesn't include 16-bit systems, and only modern systems
-   (that certainly have <limits.h>) have 64+-bit integral types.  */
-
-# ifndef INT_MAX
-#  define INT_MAX INT_MAX_32_BITS
-# endif
-
-# if INT_MAX == INT_MAX_32_BITS
-   typedef unsigned int sha1_uint32;
-# else
-#  if SHRT_MAX == INT_MAX_32_BITS
-    typedef unsigned short sha1_uint32;
-#  else
-#   if LONG_MAX == INT_MAX_32_BITS
-     typedef unsigned long sha1_uint32;
-#   else
-     /* The following line is intended to evoke an error.
-        Using #error is not portable enough.  */
-     "Cannot determine unsigned 32-bit data type."
-#   endif
-#  endif
-# endif
-#endif
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/* Structure to save state of computation between the single steps.  */
-struct sha1_ctx
-{
-  sha1_uint32 A;
-  sha1_uint32 B;
-  sha1_uint32 C;
-  sha1_uint32 D;
-  sha1_uint32 E;
-
-  sha1_uint32 total[2];
-  sha1_uint32 buflen;
-  sha1_uint32 buffer[32];
-};
-
-
-/* Initialize structure containing state of computation. */
-extern void sha1_init_ctx (struct sha1_ctx *ctx);
-
-/* Starting with the result of former calls of this function (or the
-   initialization function update the context for the next LEN bytes
-   starting at BUFFER.
-   It is necessary that LEN is a multiple of 64!!! */
-extern void sha1_process_block (const void *buffer, size_t len,
-				struct sha1_ctx *ctx);
-
-/* Starting with the result of former calls of this function (or the
-   initialization function update the context for the next LEN bytes
-   starting at BUFFER.
-   It is NOT required that LEN is a multiple of 64.  */
-extern void sha1_process_bytes (const void *buffer, size_t len,
-				struct sha1_ctx *ctx);
-
-/* Process the remaining bytes in the buffer and put result from CTX
-   in first 20 bytes following RESBUF.  The result is always in little
-   endian byte order, so that a byte-wise output yields to the wanted
-   ASCII representation of the message digest.
-
-   IMPORTANT: On some systems it is required that RESBUF be correctly
-   aligned for a 32 bits value.  */
-extern void *sha1_finish_ctx (struct sha1_ctx *ctx, void *resbuf);
-
-
-/* Put result from CTX in first 20 bytes following RESBUF.  The result is
-   always in little endian byte order, so that a byte-wise output yields
-   to the wanted ASCII representation of the message digest.
-
-   IMPORTANT: On some systems it is required that RESBUF is correctly
-   aligned for a 32 bits value.  */
-extern void *sha1_read_ctx (const struct sha1_ctx *ctx, void *resbuf);
-
-
-/* Compute SHA1 message digest for bytes read from STREAM.  The
-   resulting message digest number will be written into the 20 bytes
-   beginning at RESBLOCK.  */
-extern int sha1_stream (FILE *stream, void *resblock);
-
-/* Compute SHA1 message digest for LEN bytes beginning at BUFFER.  The
-   result is always in little endian byte order, so that a byte-wise
-   output yields to the wanted ASCII representation of the message
-   digest.  */
-extern void *sha1_buffer (const char *buffer, size_t len, void *resblock);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif


From mark@klomp.org  Wed Oct  2 11:12:32 2024
From: mark@klomp.org (Mark Wielaard)
Date: Wed, 02 Oct 2024 13:12:32 +0200
Subject: [patch] switch to xxhash for buildid recomputation
In-Reply-To: <20241001224553.GA27163@redhat.com>
References: <20240927191441.GF15164@redhat.com>
 <20240929213922.GH3393@gnu.wildebeest.org>
 <20241001213205.GF25397@redhat.com>
 <20241001221533.GC17463@gnu.wildebeest.org>
 <20241001224553.GA27163@redhat.com>
Message-ID: <1c85a87ce91624c21fdd8d40f88b3b089c9e4039.camel@klomp.org>

HI Frank,

On Tue, 2024-10-01 at 18:45 -0400, Frank Ch. Eigler wrote:
> > > Replaced with a pkgconfig check.
> > 
> > OK, but why check for libxxhash >= 0.8.2?  Isn't >= 0.8.0 enough?  It
> > would exclude debian stable (0.8.1) and I would really like debuginfo
> > to build on that.
> 
> Even RHEL7 EPEL had 0.8.2, so I figured that was fine.  I'll change it
> to 0.8.1 for our debian pals, and hope the buildbots speak up if there's
> a problem.

The buildbots only have a handful of distros and arches. There are
certainly setups out there that have different libxxhash versions
installed. We know we need at least 0.8.0, but do we need 0.8.1+? Is
there something bad in 0.8.0 so we cannot require that version?

> > > OK, v2:
> > 
> > well... it is more like a diff against v1, except for the testcase?
> 
> Whoops, sorry, resending.

Looks good (modulo the 0.8.0 vs 0.8.1 thing discussed above).

Thanks,

Mark

P.S. Do note that sending patches in git send-email or format-patch
format makes it slightly easier to apply and test locally. Neither git
am nor b4 will recognize the diff as the proposed commit. You can apply
it locally with some tweaks, but it isn't really what you are about to
commit.

From fche@redhat.com  Wed Oct  2 12:26:55 2024
From: fche@redhat.com (Frank Ch. Eigler)
Date: Wed, 2 Oct 2024 08:26:55 -0400
Subject: [patch] switch to xxhash for buildid recomputation
In-Reply-To: <1c85a87ce91624c21fdd8d40f88b3b089c9e4039.camel@klomp.org>
References: <20240927191441.GF15164@redhat.com>
 <20240929213922.GH3393@gnu.wildebeest.org>
 <20241001213205.GF25397@redhat.com>
 <20241001221533.GC17463@gnu.wildebeest.org>
 <20241001224553.GA27163@redhat.com>
 <1c85a87ce91624c21fdd8d40f88b3b089c9e4039.camel@klomp.org>
Message-ID: <20241002122655.GB27163@redhat.com>

Hi -

> [...] We know we need at least 0.8.0, but do we need 0.8.1+? Is
> there something bad in 0.8.0 so we cannot require that version?

I don't know.  A x86-64 build with the old f35 xxhash-devel headers
does pass the tests.  My point about buildbots was that it is one way
we can find out.

> [...]
> Looks good (modulo the 0.8.0 vs 0.8.1 thing discussed above).

OK, switching.  Would you like me to push it to the main branch?

> P.S. Do note that sending patches in git send-email or format-patch
> format makes it slightly easier to apply and test locally. Neither git
> am nor b4 will recognize the diff as the proposed commit. You can apply
> it locally with some tweaks, but it isn't really what you are about to
> commit.

OK, FWIW, 

% curl https://inbox.sourceware.org/.../raw | git am -

is happy processing 100% of that patch, except that it puts more of
the email prose into the commit text.

- FChE


From mark@klomp.org  Wed Oct  2 13:35:31 2024
From: mark@klomp.org (Mark Wielaard)
Date: Wed, 02 Oct 2024 15:35:31 +0200
Subject: [patch] switch to xxhash for buildid recomputation
In-Reply-To: <20241002122655.GB27163@redhat.com>
References: <20240927191441.GF15164@redhat.com>
 <20240929213922.GH3393@gnu.wildebeest.org>
 <20241001213205.GF25397@redhat.com>
 <20241001221533.GC17463@gnu.wildebeest.org>
 <20241001224553.GA27163@redhat.com>
 <1c85a87ce91624c21fdd8d40f88b3b089c9e4039.camel@klomp.org>
 <20241002122655.GB27163@redhat.com>
Message-ID: <8c49e6e7a1a3524f91da1b87ccec9ffea64ae104.camel@klomp.org>

Hi Frank,

On Wed, 2024-10-02 at 08:26 -0400, Frank Ch. Eigler wrote:
> > Looks good (modulo the 0.8.0 vs 0.8.1 thing discussed above).
> 
> OK, switching.  Would you like me to push it to the main branch?

Yes please!

> > P.S. Do note that sending patches in git send-email or format-patch
> > format makes it slightly easier to apply and test locally. Neither git
> > am nor b4 will recognize the diff as the proposed commit. You can apply
> > it locally with some tweaks, but it isn't really what you are about to
> > commit.
> 
> OK, FWIW, 
> 
> % curl https://inbox.sourceware.org/.../raw | git am -
> 
> is happy processing 100% of that patch, except that it puts more of
> the email prose into the commit text.

Right. It certainly isn't disastrous. Even b4 shazam <mid> will be able
to apply it, but generates a really odd looking commit message. I am
mostly mentioning this because this is one of the reasons people say
the current git/email workflow is "sloppy" (or even claim email is
broken). In this case it means you cannot easily review the actual
commit as is. And the commit message is important. It also means that
you have to do some surgery on a commit if you want to apply it for
someone. It just inhibits some automation.

Cheers,

Mark

From fche@redhat.com  Wed Oct  2 14:51:08 2024
From: fche@redhat.com (Frank Ch. Eigler)
Date: Wed, 2 Oct 2024 10:51:08 -0400
Subject: [patch] switch to xxhash for buildid recomputation
In-Reply-To: <8c49e6e7a1a3524f91da1b87ccec9ffea64ae104.camel@klomp.org>
References: <20240927191441.GF15164@redhat.com>
 <20240929213922.GH3393@gnu.wildebeest.org>
 <20241001213205.GF25397@redhat.com>
 <20241001221533.GC17463@gnu.wildebeest.org>
 <20241001224553.GA27163@redhat.com>
 <1c85a87ce91624c21fdd8d40f88b3b089c9e4039.camel@klomp.org>
 <20241002122655.GB27163@redhat.com>
 <8c49e6e7a1a3524f91da1b87ccec9ffea64ae104.camel@klomp.org>
Message-ID: <20241002145108.GA31364@redhat.com>

Hi -

> > OK, switching.  Would you like me to push it to the main branch?
> Yes please!

Thanks, done.

> [...]
> > % curl https://inbox.sourceware.org/.../raw | git am -
> > 
> > is happy processing 100% of that patch, except that it puts more of
> > the email prose into the commit text.
> 
> Right. It certainly isn't disastrous. Even b4 shazam <mid> will be able
> to apply it, but generates a really odd looking commit message. [...]
> [...] It just inhibits some automation.

You're right.  This factor is perhaps less important for others who
have commit access already (so email is more for review than for
precious master-copy transport).

- FChE


From builder@sourceware.org  Wed Oct  2 15:10:12 2024
From: builder@sourceware.org (builder@sourceware.org)
Date: Wed, 02 Oct 2024 15:10:12 +0000
Subject: =?utf-8?q?=E2=98=A0_Buildbot_=28Sourceware=29=3A_debugedit_-_failed_configure_=28failure=29_=28main=29?=
Message-ID: <20241002151012.547523858C33@sourceware.org>

A new failure has been detected on builder debugedit-debian-armhf while building debugedit.

Full details are available at:
    https://builder.sourceware.org/buildbot/#/builders/1/builds/29

Build state: failed configure (failure)
Revision: 7f680f12774c0cece7c2da22b868c1db9639cc68
Worker: debian-armhf
Build Reason: (unknown)
Blamelist: Frank Ch. Eigler <fche@redhat.com>

Steps:

- 0: worker_preparation ( success )

- 1: set package name ( success )

- 2: git checkout ( success )
    Logs:
        - stdio: https://builder.sourceware.org/buildbot/#/builders/1/builds/29/steps/2/logs/stdio

- 3: autoreconf ( success )
    Logs:
        - stdio: https://builder.sourceware.org/buildbot/#/builders/1/builds/29/steps/3/logs/stdio

- 4: configure ( failure )
    Logs:
        - stdio: https://builder.sourceware.org/buildbot/#/builders/1/builds/29/steps/4/logs/stdio
        - config.log: https://builder.sourceware.org/buildbot/#/builders/1/builds/29/steps/4/logs/config_log


From mark@klomp.org  Wed Oct  2 22:49:01 2024
From: mark@klomp.org (Mark Wielaard)
Date: Thu, 3 Oct 2024 00:49:01 +0200
Subject: =?utf-8?B?4pigIEJ1aWxkYm8=?= =?utf-8?Q?t?= (Sourceware):
 debugedit - failed configure (failure) (main)
In-Reply-To: <20241002151012.547523858C33@sourceware.org>
References: <20241002151012.547523858C33@sourceware.org>
Message-ID: <20241002224901.GD17463@gnu.wildebeest.org>

Hi,

On Wed, Oct 02, 2024 at 03:10:12PM +0000, builder@sourceware.org wrote:
> A new failure has been detected on builder debugedit-debian-armhf while building debugedit.
> 
> Full details are available at:
>     https://builder.sourceware.org/buildbot/#/builders/1/builds/29
> 
> Build state: failed configure (failure)
> Revision: 7f680f12774c0cece7c2da22b868c1db9639cc68
> Worker: debian-armhf
> Build Reason: (unknown)
> Blamelist: Frank Ch. Eigler <fche@redhat.com>
> 
> Steps:
> 
> - 0: worker_preparation ( success )
> 
> - 1: set package name ( success )
> 
> - 2: git checkout ( success )
>     Logs:
>         - stdio: https://builder.sourceware.org/buildbot/#/builders/1/builds/29/steps/2/logs/stdio
> 
> - 3: autoreconf ( success )
>     Logs:
>         - stdio: https://builder.sourceware.org/buildbot/#/builders/1/builds/29/steps/3/logs/stdio
> 
> - 4: configure ( failure )
>     Logs:
>         - stdio: https://builder.sourceware.org/buildbot/#/builders/1/builds/29/steps/4/logs/stdio
>         - config.log: https://builder.sourceware.org/buildbot/#/builders/1/builds/29/steps/4/logs/config_log
> 

The builder is running old-old-stable Debian, which has too old xxhash.
So this failure is expected. We should really update this builder.

Cheers,

Mark

From sourceware-bugzilla@sourceware.org  Mon Oct  7 18:46:29 2024
From: sourceware-bugzilla@sourceware.org (fche at redhat dot com)
Date: Mon, 07 Oct 2024 18:46:29 +0000
Subject: [Bug debugedit/32251] New: more debugedit diagnostics
Message-ID: <bug-32251-13298@http.sourceware.org/bugzilla/>

https://sourceware.org/bugzilla/show_bug.cgi?id=32251

            Bug ID: 32251
           Summary: more debugedit diagnostics
           Product: debugedit
           Version: unspecified
            Status: NEW
          Severity: normal
          Priority: P2
         Component: debugedit
          Assignee: unassigned at sourceware dot org
          Reporter: fche at redhat dot com
                CC: debugedit at sourceware dot org
  Target Milestone: ---

When find-debuginfo runs debugedit, it consumes its stdout in a backtick to
fetch the new build-id.  It would be nice if debugedit emitted some extra
diagnostics to help with unusual situations.  These could go on stderr:

- source file rewriting stats (listed vs. rewritten)
- source file enumeration (-l) mode stats (listed vs. subdir-mismatched)
- set of directories encountered in source tree
- incoming & outgoing buildids

-- 
You are receiving this mail because:
You are on the CC list for the bug.

From oxfordshirelogs@web.wiseserve.net  Thu Oct 17 02:17:04 2024
From: oxfordshirelogs@web.wiseserve.net (oxfordshirelogs@web.wiseserve.net)
Date: Thu, 17 Oct 2024 02:17:04 +0000
Subject: We have received your inquiry
Message-ID: <YgIA221IuP4kPlKrtsZ6rRYToekB8ZB6SeJe3nWo@oxfordshirelogs.com>

An HTML attachment was scrubbed...
URL: <https://sourceware.org/pipermail/debugedit/attachments/20241017/c135f936/attachment.htm>

From mark@klomp.org  Thu Oct 24 22:59:00 2024
From: mark@klomp.org (Mark Wielaard)
Date: Fri, 25 Oct 2024 00:59:00 +0200
Subject: [PATCH 1/2] tools: sepdebugcrcfix: fix build with c23
In-Reply-To: <7891ceee8a421ee49a845bdaec82dd971d2618d4.1725061363.git.sam@gentoo.org>
References: <7891ceee8a421ee49a845bdaec82dd971d2618d4.1725061363.git.sam@gentoo.org>
Message-ID: <20241024225900.GB22055@gnu.wildebeest.org>

Hi Sam,

On Sat, Aug 31, 2024 at 12:42:42AM +0100, Sam James wrote:
> Avoid redefining bool:
> ```
>   CC       tools/sepdebugcrcfix-sepdebugcrcfix.o
> tools/sepdebugcrcfix.c:47:13: error: two or more data types in declaration specifiers
>    47 | typedef int bool;
>       |             ^~~~
> tools/sepdebugcrcfix.c:47:1: warning: useless type name in empty declaration
>    47 | typedef int bool;
>       | ^~~~~~~
> tools/sepdebugcrcfix.c:48:19: error: expected identifier or ?(? before ?false?
>    48 | static const bool false = 0, true = 1;
>       |                   ^~~~~
> ```
> 
> While here, include `<stdbool.h>` for older C standards than C23.

OK, that does makes us rely on at least C99, but we already have an
AC_CHECK_HEADERS for stdint, which also requires at least C99.

Pushed,

Mark


From mark@klomp.org  Thu Oct 24 23:00:47 2024
From: mark@klomp.org (Mark Wielaard)
Date: Fri, 25 Oct 2024 01:00:47 +0200
Subject: [PATCH 2/2] tools: sepdebugcrcfix: sort includes
In-Reply-To: <e9131de83045e1cc00b7be6486860c7c6596fd05.1725061363.git.sam@gentoo.org>
References: <7891ceee8a421ee49a845bdaec82dd971d2618d4.1725061363.git.sam@gentoo.org>
 <e9131de83045e1cc00b7be6486860c7c6596fd05.1725061363.git.sam@gentoo.org>
Message-ID: <20241024230047.GC22055@gnu.wildebeest.org>

Hi Sam,

Looks good.

Pushed,

Mark


From mark@klomp.org  Thu Oct 24 23:05:06 2024
From: mark@klomp.org (Mark Wielaard)
Date: Fri, 25 Oct 2024 01:05:06 +0200
Subject: [PATCH] scripts: find-debuginfo: mention MiniDebugInfo for -m
In-Reply-To: <4c512b7ff4438cf70e2fdb6297a34682d9cef284.1725061391.git.sam@gentoo.org>
References: <4c512b7ff4438cf70e2fdb6297a34682d9cef284.1725061391.git.sam@gentoo.org>
Message-ID: <20241024230506.GD22055@gnu.wildebeest.org>

Hi Sam,

Good idea. I think the correct term would be "MiniSymtab" but
everybody else calls it MiniDebugInfo so lets go with that.

Pushed,

Mark

From mark@klomp.org  Mon Oct 28 13:30:15 2024
From: mark@klomp.org (Mark Wielaard)
Date: Mon, 28 Oct 2024 14:30:15 +0100
Subject: [PATCH] debugedit: decompress (and recompress) DWARF sections
Message-ID: <20241028133015.3213072-1-mark@klomp.org>

From: Morten Linderud <morten@linderud.pw>

When encountering compressed DWARF section try to decompress them
before rewriting. Afterwards recompress them. All this is
automatic. No new command line options.

Decompression was added by Morten, Mark then added recompression.

The recompression support needed a bit of workaround for an elfutils
< 0.192 bug https://sourceware.org/bugzilla/show_bug.cgi?id=32102

Various new tests were added. In debugedit.at DEBUGEDIT_SETUP now
takes an (optional) second arg to set the -gz=... option. readelf is
now called with -zp to automatically decompress any compressed
data/string sections.

https://sourceware.org/bugzilla/show_bug.cgi?id=27636

Signed-off-by: Morten Linderud <morten@linderud.pw>
Signed-off-by: Mark Wielaard <mark@klomp.org>
---
 configure.ac       |  13 ++++
 tests/atlocal.in   |   1 +
 tests/debugedit.at | 179 ++++++++++++++++++++++++++++++++++++++-------
 tools/debugedit.c  |  88 +++++++++++++++++++---
 4 files changed, 245 insertions(+), 36 deletions(-)

diff --git a/configure.ac b/configure.ac
index f0065c9932f4..96922267b7fe 100644
--- a/configure.ac
+++ b/configure.ac
@@ -136,6 +136,19 @@ else
 fi
 AC_SUBST([GZ_NONE_FLAG])
 
+AC_CACHE_CHECK([whether gcc supports -gz=zlib], ac_cv_gz_zlib, [dnl
+save_CFLAGS="$CFLAGS"
+CFLAGS="-gz=zlib"
+AC_LINK_IFELSE([AC_LANG_PROGRAM()], ac_cv_gz_zlib=yes, ac_cv_gz_zlib=no)
+CFLAGS="$save_CFLAGS"
+])
+if test "$ac_cv_gz_zlib" = "yes"; then
+  GZ_ZLIB_FLAG="-gz=zlib"
+else
+  GZ_ZLIB_FLAG=""
+fi
+AC_SUBST([GZ_ZLIB_FLAG])
+
 AC_CACHE_CHECK([whether compiler needs -fdebug-macro], ac_cv_debug_macro, [dnl
 save_CFLAGS="$CFLAGS"
 CFLAGS="-fdebug-macro"
diff --git a/tests/atlocal.in b/tests/atlocal.in
index 01b998c83c7f..d3364d3e9e58 100644
--- a/tests/atlocal.in
+++ b/tests/atlocal.in
@@ -13,5 +13,6 @@ READELF="@READELF@"
 
 GDWARF_5_FLAG=@GDWARF_5_FLAG@
 GZ_NONE_FLAG=@GZ_NONE_FLAG@
+GZ_ZLIB_FLAG=@GZ_ZLIB_FLAG@
 DWARF_5_DEBUGLINE=@DWARF_5_DEBUGLINE@
 DEBUG_MACRO_FLAG=@DEBUG_MACRO_FLAG@
diff --git a/tests/debugedit.at b/tests/debugedit.at
index 94b0caee5423..b125e627546d 100644
--- a/tests/debugedit.at
+++ b/tests/debugedit.at
@@ -1,6 +1,6 @@
 # debugedit.at: Tests for the debugedit tool
 #
-# Copyright (C) 2019 Mark J. Wielaard <mark@klomp.org>
+# Copyright (C) 2019, 2024 Mark J. Wielaard <mark@klomp.org>
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -22,7 +22,11 @@ AT_BANNER([debugedit])
 AT_TESTED([debugedit])
 
 # Helper to create some test binaries.
-# Optional parameter can specify additional gcc parameters.
+# Optional fist parameter can specify additional gcc parameters.
+# e.g. -gdwarf-4 or -gdwarf-5 for explicit DWARF version.
+# -g3 is always given. Second parameter can be a compression flag
+# like $GZ_ZLIB_FLAG (if it exists), when not given $GZ_NONE_FLAG
+# is used.
 m4_define([DEBUGEDIT_SETUP],[[
 # Create some test binaries. Create and build them in different subdirs
 # to make sure they produce different relative/absolute paths.
@@ -36,12 +40,19 @@ mkdir subdir_headers
 cp "${abs_srcdir}"/data/SOURCES/foobar.h subdir_headers
 cp "${abs_srcdir}"/data/SOURCES/baz.c .
 
+# Check second param, if given use compression
+if test -z "$2"; then
+GZ_FLAG=$GZ_NONE_FLAG
+else
+GZ_FLAG=$2
+fi
+
 # First three object files (foo.o subdir_bar/bar.o and baz.o)
-$CC $CFLAGS -g3 $GZ_NONE_FLAG -Isubdir_headers $1 -c subdir_foo/foo.c
+$CC $CFLAGS -g3 $GZ_FLAG -Isubdir_headers $1 -c subdir_foo/foo.c
 cd subdir_bar
-$CC $CFLAGS -g3 $GZ_NONE_FLAG -I../subdir_headers $1 -c bar.c
+$CC $CFLAGS -g3 $GZ_FLAG -I../subdir_headers $1 -c bar.c
 cd ..
-$CC $CFLAGS -g3 $GZ_NONE_FLAG -I$(pwd)/subdir_headers $1 -c $(pwd)/baz.c
+$CC $CFLAGS -g3 $GZ_FLAG -I$(pwd)/subdir_headers $1 -c $(pwd)/baz.c
 
 # Then a partially linked object file (somewhat like a kernel module).
 # This will still have relocations between the debug sections.
@@ -49,7 +60,7 @@ $LD $LDFLAGS -r -o foobarbaz.part.o foo.o subdir_bar/bar.o baz.o
 
 # Create an executable. Relocations between debug sections will
 # have been resolved.
-$CC $CFLAGS -g3 $GZ_NONE_FLAG -o foobarbaz.exe foo.o subdir_bar/bar.o baz.o
+$CC $CFLAGS -g3 $GZ_FLAG $1 -o foobarbaz.exe foo.o subdir_bar/bar.o baz.o
 ]])
 
 # ===
@@ -83,6 +94,17 @@ AT_CHECK([[./foobarbaz.exe]])
 
 AT_CLEANUP
 
+AT_SETUP([debugedit executable (compressed)])
+AT_KEYWORDS([debuginfo] [debugedit])
+AT_SKIP_IF([test -z "$GZ_ZLIB_FLAG"])
+DEBUGEDIT_SETUP([], [$GZ_ZLIB_FLAG])
+
+AT_CHECK([[./foobarbaz.exe]])
+AT_CHECK([[debugedit -b $(pwd) -d /foo/bar/baz ./foobarbaz.exe]])
+AT_CHECK([[./foobarbaz.exe]])
+
+AT_CLEANUP
+
 # ===
 # debugedit should at least replace the .debug_str directory paths
 # in the objects.
@@ -93,9 +115,9 @@ DEBUGEDIT_SETUP([-gdwarf-4])
 
 # Capture strings that start with the testdir (pwd) directory path
 # (and replace that textually with /foo/bar/baz)
-($READELF -p.debug_str foo.o; \
- $READELF -p.debug_str subdir_bar/bar.o; \
- $READELF -p.debug_str baz.o) \
+($READELF -zp.debug_str foo.o; \
+ $READELF -zp.debug_str subdir_bar/bar.o; \
+ $READELF -zp.debug_str baz.o) \
 	| cut -c13- \
         | grep ^$(pwd) | sort \
         | sed -e "s@$(pwd)@/foo/bar/baz@" > expout
@@ -111,9 +133,9 @@ AT_CHECK([[debugedit -b $(pwd) -d /foo/bar/baz ./foo.o]])
 AT_CHECK([[debugedit -b $(pwd) -d /foo/bar/baz ./subdir_bar/bar.o]])
 AT_CHECK([[debugedit -b $(pwd) -d /foo/bar/baz ./baz.o]])
 AT_CHECK([[
-($READELF -p.debug_str foo.o; \
- $READELF -p.debug_str subdir_bar/bar.o; \
- $READELF -p.debug_str baz.o) \
+($READELF -zp.debug_str foo.o; \
+ $READELF -zp.debug_str subdir_bar/bar.o; \
+ $READELF -zp.debug_str baz.o) \
 	| cut -c13- \
         | grep ^/foo/bar/baz | sort
 ]],[0],[expout])
@@ -131,9 +153,9 @@ DEBUGEDIT_SETUP([-gdwarf-5])
 
 # Capture strings that start with the testdir (pwd) directory path
 # (and replace that textually with /foo/bar/baz)
-($READELF -p.debug_str -p.debug_line_str foo.o; \
- $READELF -p.debug_str -p.debug_line_str subdir_bar/bar.o; \
- $READELF -p.debug_str -p.debug_line_str baz.o) \
+($READELF -zp.debug_str -zp.debug_line_str foo.o; \
+ $READELF -zp.debug_str -zp.debug_line_str subdir_bar/bar.o; \
+ $READELF -zp.debug_str -zp.debug_line_str baz.o) \
         | cut -c13- \
         | grep ^$(pwd) | sort | uniq \
         | sed -e "s@$(pwd)@/foo/bar/baz@" > expout
@@ -149,9 +171,9 @@ AT_CHECK([[debugedit -b $(pwd) -d /foo/bar/baz ./foo.o]])
 AT_CHECK([[debugedit -b $(pwd) -d /foo/bar/baz ./subdir_bar/bar.o]])
 AT_CHECK([[debugedit -b $(pwd) -d /foo/bar/baz ./baz.o]])
 AT_CHECK([[
-($READELF -p.debug_str -p.debug_line_str foo.o; \
- $READELF -p.debug_str -p.debug_line_str subdir_bar/bar.o; \
- $READELF -p.debug_str -p.debug_line_str baz.o) \
+($READELF -zp.debug_str -zp.debug_line_str foo.o; \
+ $READELF -zp.debug_str -zp.debug_line_str subdir_bar/bar.o; \
+ $READELF -zp.debug_str -zp.debug_line_str baz.o) \
         | cut -c13- \
         | grep ^/foo/bar/baz | sort | uniq
 ]],[0],[expout],[ignore])
@@ -170,7 +192,7 @@ DEBUGEDIT_SETUP([-gdwarf-4])
 # (and replace that textually with /foo/bar/baz)
 # Note that partially linked files, might have multiple duplicate
 # strings, but debugedit will merge them. So use sort -u.
-$READELF -p.debug_str ./foobarbaz.part.o | cut -c13- \
+$READELF -zp.debug_str ./foobarbaz.part.o | cut -c13- \
         | grep ^$(pwd) | sort -u \
         | sed -e "s@$(pwd)@/foo/bar/baz@" > expout
 
@@ -183,7 +205,7 @@ fi
 # Check the replaced strings are all there.
 AT_CHECK([[debugedit -b $(pwd) -d /foo/bar/baz ./foobarbaz.part.o]])
 AT_CHECK([[
-$READELF -p.debug_str ./foobarbaz.part.o | cut -c13- \
+$READELF -zp.debug_str ./foobarbaz.part.o | cut -c13- \
         | grep ^/foo/bar/baz | sort
 ]],[0],[expout])
 
@@ -202,7 +224,7 @@ DEBUGEDIT_SETUP([-gdwarf-5])
 # (and replace that textually with /foo/bar/baz)
 # Note that partially linked files, might have multiple duplicate
 # strings, but debugedit will merge them. So use sort -u.
-$READELF -p.debug_str -p.debug_line_str ./foobarbaz.part.o | cut -c13- \
+$READELF -zp.debug_str -zp.debug_line_str ./foobarbaz.part.o | cut -c13- \
         | grep ^$(pwd) | sort -u | uniq \
         | sed -e "s@$(pwd)@/foo/bar/baz@" > expout
 
@@ -215,7 +237,7 @@ fi
 # Check the replaced strings are all there.
 AT_CHECK([[debugedit -b $(pwd) -d /foo/bar/baz ./foobarbaz.part.o]])
 AT_CHECK([[
-$READELF -p.debug_str -p.debug_line_str ./foobarbaz.part.o | cut -c13- \
+$READELF -zp.debug_str -zp.debug_line_str ./foobarbaz.part.o | cut -c13- \
         | grep ^/foo/bar/baz | sort | uniq
 ]],[0],[expout],[ignore])
 
@@ -231,7 +253,7 @@ DEBUGEDIT_SETUP([-gdwarf-4])
 
 # Capture strings that start with the testdir (pwd) directory path
 # (and replace that textually with /foo/bar/baz)
-$READELF -p.debug_str foobarbaz.exe | cut -c13- \
+$READELF -zp.debug_str foobarbaz.exe | cut -c13- \
         | grep ^$(pwd) | sort \
         | sed -e "s@$(pwd)@/foo/bar/baz@" > expout
 
@@ -245,7 +267,7 @@ fi
 # Check the replaced strings are all there.
 AT_CHECK([[debugedit -b $(pwd) -d /foo/bar/baz ./foobarbaz.exe]])
 AT_CHECK([[
-$READELF -p.debug_str foobarbaz.exe | cut -c13- \
+$READELF -zp.debug_str foobarbaz.exe | cut -c13- \
         | grep ^/foo/bar/baz | sort
 ]],[0],[expout])
 
@@ -262,7 +284,7 @@ DEBUGEDIT_SETUP([-gdwarf-5])
 
 # Capture strings that start with the testdir (pwd) directory path
 # (and replace that textually with /foo/bar/baz)
-$READELF -p.debug_str -p.debug_line_str foobarbaz.exe | cut -c13- \
+$READELF -zp.debug_str -zp.debug_line_str foobarbaz.exe | cut -c13- \
         | grep ^$(pwd) | sort | uniq \
         | sed -e "s@$(pwd)@/foo/bar/baz@" > expout
 
@@ -276,7 +298,7 @@ fi
 # Check the replaced strings are all there.
 AT_CHECK([[debugedit -b $(pwd) -d /foo/bar/baz ./foobarbaz.exe]])
 AT_CHECK([[
-$READELF -p.debug_str -p.debug_line_str foobarbaz.exe | cut -c13- \
+$READELF -zp.debug_str -zp.debug_line_str foobarbaz.exe | cut -c13- \
         | grep ^/foo/bar/baz | sort | uniq
 ]],[0],[expout],[ignore])
 
@@ -324,6 +346,30 @@ AT_CHECK([[
 
 AT_CLEANUP
 
+AT_SETUP([debugedit .debug_info objects (compressed)])
+AT_KEYWORDS([debuginfo] [debugedit])
+AT_SKIP_IF([test -z "$GZ_ZLIB_FLAG"])
+DEBUGEDIT_SETUP([], [$GZ_ZLIB_FLAG])
+
+AT_DATA([expout],
+[/foo/bar/baz
+/foo/bar/baz/baz.c
+/foo/bar/baz/subdir_bar
+])
+
+AT_CHECK([[debugedit -b $(pwd) -d /foo/bar/baz ./foo.o]])
+AT_CHECK([[debugedit -b $(pwd) -d /foo/bar/baz ./subdir_bar/bar.o]])
+AT_CHECK([[debugedit -b $(pwd) -d /foo/bar/baz ./baz.o]])
+AT_CHECK([[
+($READELF --debug-dump=info foo.o; \
+ $READELF --debug-dump=info subdir_bar/bar.o; \
+ $READELF --debug-dump=info baz.o) \
+        | grep -E 'DW_AT_(name|comp_dir)' \
+        | rev | cut -d: -f1 | rev | cut -c2- | grep ^/foo/bar/baz | sort -u
+]],[0],[expout])
+
+AT_CLEANUP
+
 # ===
 # Make sure DW_AT_name and DW_AT_comp_dir strings are replaced
 # in partial linked object.
@@ -347,6 +393,26 @@ $READELF --debug-dump=info ./foobarbaz.part.o \
 
 AT_CLEANUP
 
+AT_SETUP([debugedit .debug_info partial (compressed)])
+AT_KEYWORDS([debuginfo] [debugedit])
+AT_SKIP_IF([test -z "$GZ_ZLIB_FLAG"])
+DEBUGEDIT_SETUP([], [$GZ_ZLIB_FLAG])
+
+AT_DATA([expout],
+[/foo/bar/baz
+/foo/bar/baz/baz.c
+/foo/bar/baz/subdir_bar
+])
+
+AT_CHECK([[debugedit -b $(pwd) -d /foo/bar/baz ./foobarbaz.part.o]])
+AT_CHECK([[
+$READELF --debug-dump=info ./foobarbaz.part.o \
+        | grep -E 'DW_AT_(name|comp_dir)' \
+        | rev | cut -d: -f1 | rev | cut -c2- | grep ^/foo/bar/baz | sort -u
+]],[0],[expout])
+
+AT_CLEANUP
+
 # ===
 # Make sure DW_AT_name and DW_AT_comp_dir strings are replaced
 # in executable.
@@ -369,6 +435,25 @@ $READELF --debug-dump=info ./foobarbaz.exe | grep -E 'DW_AT_(name|comp_dir)' \
 
 AT_CLEANUP
 
+AT_SETUP([debugedit .debug_info exe (compressed)])
+AT_KEYWORDS([debuginfo] [debugedit])
+AT_SKIP_IF([test -z "$GZ_ZLIB_FLAG"])
+DEBUGEDIT_SETUP([], [$GZ_ZLIB_FLAG])
+
+AT_DATA([expout],
+[/foo/bar/baz
+/foo/bar/baz/baz.c
+/foo/bar/baz/subdir_bar
+])
+
+AT_CHECK([[debugedit -b $(pwd) -d /foo/bar/baz ./foobarbaz.exe]])
+AT_CHECK([[
+$READELF --debug-dump=info ./foobarbaz.exe | grep -E 'DW_AT_(name|comp_dir)' \
+        | rev | cut -d: -f1 | rev | cut -c2- | grep ^/foo/bar/baz | sort -u
+]],[0],[expout])
+
+AT_CLEANUP
+
 # ===
 # Make sure -fdebug-types-section has updated strings in objects.
 # Currently only works with DWARF4
@@ -725,6 +810,26 @@ $READELF --debug-dump=macro ./foobarbaz.exe \
 
 AT_CLEANUP
 
+AT_SETUP([debugedit .debug_macro exe (compressed)])
+AT_KEYWORDS([debuginfo] [debugedit])
+AT_SKIP_IF([test -z "$GZ_ZLIB_FLAG"])
+DEBUGEDIT_SETUP([$DEBUG_MACRO_FLAG], [$GZ_ZLIB_FLAG])
+
+# We expect 3 for each compile unit.
+AT_DATA([expout],
+[NUMBER 42
+NUMBER 42
+NUMBER 42
+])
+
+AT_CHECK([[debugedit -b $(pwd) -d /foo/bar/baz ./foobarbaz.exe]])
+AT_CHECK([[
+$READELF --debug-dump=macro ./foobarbaz.exe \
+        | grep NUMBER | rev | cut -d: -f1 | rev | cut -c2-
+]],[0],[expout])
+
+AT_CLEANUP
+
 # ===
 # source list mode dwarf-4
 # ===
@@ -749,6 +854,28 @@ AT_CHECK([[debugedit -l sources.list main]])
 AT_CHECK([[grep -q main.c sources.list]])
 AT_CLEANUP
 
+# ===
+# source list with compression dwarf-4
+# ===
+AT_SETUP([debugedit --list-file compressed DWARF4])
+AT_KEYWORDS([debuginfo] [debugedit])
+echo "int main () { }" > main.c
+$CC $CFLAGS $GZ_ZLIB_FLAG -gdwarf-4 -o main main.c
+AT_CHECK([[debugedit -l sources.list main]])
+AT_CHECK([[grep -q main.c sources.list]])
+AT_CLEANUP
+
+# ===
+# source list with compression dwarf-5
+# ===
+AT_SETUP([debugedit --list-file compressed DWARF5])
+AT_KEYWORDS([debuginfo] [debugedit])
+AT_SKIP_IF([test "$GDWARF_5_FLAG" = "no"])
+echo "int main () { }" > main.c
+$CC $CFLAGS $GZ_ZLIB_FLAG -gdwarf-5 -o main main.c
+AT_CHECK([[debugedit -l sources.list main]])
+AT_CHECK([[grep -q main.c sources.list]])
+AT_CLEANUP
 
 # ===
 # build-id recomputation
diff --git a/tools/debugedit.c b/tools/debugedit.c
index 6712f0fca2d0..beefd65bab6a 100644
--- a/tools/debugedit.c
+++ b/tools/debugedit.c
@@ -41,6 +41,7 @@
 
 #include <gelf.h>
 #include <dwarf.h>
+#include <libelf.h>
 
 #ifndef MAX
 #define MAX(m, n) ((m) < (n) ? (n) : (m))
@@ -118,6 +119,10 @@ static bool need_line_strp_update = false;
    DW_AT_stmt_list attributes indexes in the debug_info. */
 static bool need_stmt_update = false;
 
+/* If we recompress any debug section we need to write out the ELF
+   again. */
+static bool recompressed = false;
+
 /* Storage for dynamically allocated strings to put into string
    table. Keep together in memory blocks of 16K. */
 #define STRMEMSIZE (16 * 1024)
@@ -250,6 +255,7 @@ typedef struct debug_section
     REL *relbuf;
     REL *relend;
     bool rel_updated;
+    uint32_t ch_type;
     /* Only happens for COMDAT .debug_macro and .debug_types.  */
     struct debug_section *next;
   } debug_section;
@@ -1503,16 +1509,22 @@ static void
 edit_dwarf2_line (DSO *dso)
 {
   Elf_Data *linedata = debug_sections[DEBUG_LINE].elf_data;
-  int linendx = debug_sections[DEBUG_LINE].sec;
-  Elf_Scn *linescn = dso->scn[linendx];
   unsigned char *old_buf = linedata->d_buf;
 
-  /* Out with the old. */
-  linedata->d_size = 0;
+  /* A nicer way to do this would be to set the original d_size to
+     zero and add a new Elf_Data section to contain the new data.
+     Out with the old. In with the new.
 
-  /* In with the new. */
+  int linendx = debug_sections[DEBUG_LINE].sec;
+  Elf_Scn *linescn = dso->scn[linendx];
+  linedata->d_size = 0;
   linedata = elf_newdata (linescn);
 
+    But when we then (recompress) the section there is a bug in
+    elfutils < 0.192 that causes the compression to fail/create bad
+    compressed data. So we just reuse the existing linedata (possibly
+    loosing track of the original d_buf, which will be overwritten).  */
+
   dso->lines.line_buf = malloc (dso->lines.debug_lines_len);
   if (dso->lines.line_buf == NULL)
     error (1, ENOMEM, "No memory for new .debug_line table (0x%zx bytes)",
@@ -1660,6 +1672,7 @@ edit_dwarf2_line (DSO *dso)
       memcpy (ptr, optr, remaining);
       ptr += remaining;
     }
+  elf_flagdata (linedata, ELF_C_SET, ELF_F_DIRTY);
 }
 
 /* Record or adjust (according to phase) DW_FORM_strp or DW_FORM_line_strp.
@@ -2744,20 +2757,28 @@ edit_dwarf2_any_str (DSO *dso, struct strings *strings, debug_section *secp)
 {
   Strtab *strtab = strings->str_tab;
   Elf_Data *strdata = secp->elf_data;
+
+  /* A nicer way to do this would be to set the original d_size to
+     zero and add a new Elf_Data section to contain the new data.
+     Out with the old. In with the new.
+
   int strndx = secp->sec;
   Elf_Scn *strscn = dso->scn[strndx];
-
-  /* Out with the old. */
   strdata->d_size = 0;
-  /* In with the new. */
   strdata = elf_newdata (strscn);
 
+    But when we then (recompress) the section there is a bug in
+    elfutils < 0.192 that causes the compression to fail/create bad
+    compressed data. So we just reuse the existing strdata (possibly
+    loosing track of the original d_buf, which will be overwritten).  */
+
   /* We really should check whether we had enough memory,
      but the old ebl version will just abort on out of
      memory... */
   strtab_finalize (strtab, strdata);
   secp->size = strdata->d_size;
   strings->str_buf = strdata->d_buf;
+  elf_flagdata (strdata, ELF_C_SET, ELF_F_DIRTY);
 }
 
 /* Rebuild .debug_str_offsets.  */
@@ -2869,6 +2890,22 @@ edit_dwarf2 (DSO *dso)
 		    }
 
 		  scn = dso->scn[i];
+
+		  /* Check for compressed DWARF headers. Records
+		     ch_type so we can recompress headers after we
+		     processed the data.  */
+		  if (dso->shdr[i].sh_flags & SHF_COMPRESSED)
+		    {
+		      GElf_Chdr chdr;
+		      if (gelf_getchdr(dso->scn[i], &chdr) == NULL)
+			error (1, 0, "Couldn't get compressed header: %s",
+			       elf_errmsg (-1));
+		      debug_sec->ch_type = chdr.ch_type;
+		      if (elf_compress (scn, 0, 0) < 0)
+			error (1, 0, "Failed decompression");
+		      gelf_getshdr (scn, &dso->shdr[i]);
+		    }
+
 		  data = elf_getdata (scn, NULL);
 		  assert (data != NULL && data->d_buf != NULL);
 		  assert (elf_getdata (scn, data) == NULL);
@@ -3743,6 +3780,35 @@ main (int argc, char *argv[])
 	}
     }
 
+  /* Recompress any debug sections that might have been uncompressed.  */
+  if (dirty_elf)
+    for (int s = 0; debug_sections[s].name; s++)
+      {
+	for (struct debug_section *secp = &debug_sections[s]; secp != NULL;
+	     secp = secp->next)
+	  {
+	    if (secp->ch_type != 0)
+	      {
+		int sec = secp->sec;
+		Elf_Scn *scn = dso->scn[sec];
+		GElf_Shdr shdr = dso->shdr[sec];
+		Elf_Data *data;
+		data = elf_getdata (scn, NULL);
+		if (elf_compress (scn, secp->ch_type, 0) < 0)
+		  error (1, 0, "Failed recompression");
+		gelf_getshdr (scn, &shdr);
+		dso->shdr[secp->sec] = shdr;
+		data = elf_getdata (scn, NULL);
+		secp->elf_data = data;
+		secp->data = data->d_buf;
+		secp->size = data->d_size;
+		elf_flagshdr (scn, ELF_C_SET, ELF_F_DIRTY);
+		elf_flagdata (data, ELF_C_SET, ELF_F_DIRTY);
+		recompressed = 1;
+	      }
+	  }
+      }
+
   /* Normally we only need to explicitly update the section headers
      and data when any section data changed size. But because of a bug
      in elfutils before 0.169 we will have to update and write out all
@@ -3750,7 +3816,8 @@ main (int argc, char *argv[])
      set). https://sourceware.org/bugzilla/show_bug.cgi?id=21199 */
   bool need_update = (need_strp_update
 		      || need_line_strp_update
-		      || need_stmt_update);
+		      || need_stmt_update
+		      || recompressed);
 
 #if !_ELFUTILS_PREREQ (0, 169)
   /* string replacements or build_id updates don't change section size. */
@@ -3887,7 +3954,8 @@ main (int argc, char *argv[])
        || need_line_strp_update
        || need_stmt_update
        || dirty_elf
-       || (build_id && !no_recompute_build_id))
+       || (build_id && !no_recompute_build_id)
+       || recompressed)
       && elf_update (dso->elf, ELF_C_WRITE) < 0)
     {
       error (1, 0, "Failed to write file: %s", elf_errmsg (elf_errno()));
-- 
2.47.0


From sourceware-bugzilla@sourceware.org  Mon Oct 28 13:31:52 2024
From: sourceware-bugzilla@sourceware.org (mark at klomp dot org)
Date: Mon, 28 Oct 2024 13:31:52 +0000
Subject: [Bug debugedit/27636] Debugedit doesn't handle compressed debug ELF
 sections
In-Reply-To: <bug-27636-13298@http.sourceware.org/bugzilla/>
References: <bug-27636-13298@http.sourceware.org/bugzilla/>
Message-ID: <bug-27636-13298-T0yow52ldA@http.sourceware.org/bugzilla/>

https://sourceware.org/bugzilla/show_bug.cgi?id=27636

Mark Wielaard <mark at klomp dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
           Assignee|unassigned at sourceware dot org   |mark at klomp dot org

--- Comment #5 from Mark Wielaard <mark at klomp dot org> ---
Sorry this took so long, I worked around the elfutils bug (even though it is
now fixed in 0.192):
https://inbox.sourceware.org/debugedit/20241028133015.3213072-1-mark@klomp.org/

-- 
You are receiving this mail because:
You are on the CC list for the bug.

From mark@klomp.org  Mon Oct 28 14:14:05 2024
From: mark@klomp.org (Mark Wielaard)
Date: Mon, 28 Oct 2024 15:14:05 +0100
Subject: [COMMITTED] Add debugedit try builders
Message-ID: <20241028141405.3228114-1-mark@klomp.org>

---
 builder/master.cfg | 174 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 174 insertions(+)

diff --git a/builder/master.cfg b/builder/master.cfg
index 38f8e3383d19..1fd3101544a0 100644
--- a/builder/master.cfg
+++ b/builder/master.cfg
@@ -902,6 +902,31 @@ debugedit_scheduler = schedulers.SingleBranchScheduler(
                       "debugedit-opensuseleap-x86_64"])
 c['schedulers'].append(debugedit_scheduler)
 
+debugedit_try_scheduler = schedulers.AnyBranchScheduler(
+        name="debugedit-try",
+        change_filter=util.ChangeFilter(project="debugedit",
+                                        branch_re=re.compile("users/[a-zA-Z0-9]+/try-")),
+        treeStableTimer=10,
+        reason="debugedit project users try branch update",
+        builderNames=["debugedit-try-alma-x86_64",
+#                      "debugedit-try-debian-arm64",
+                      "debugedit-try-fedora-arm64",
+                      "debugedit-try-gentoo-sparc",
+                      "debugedit-try-fedora-x86_64",
+                      "debugedit-try-fedora-clang-x86_64",
+#                      "debugedit-try-rawhide-x86_64",
+#                      "debugedit-try-debian-testing-x86_64",
+                      "debugedit-try-debian-amd64",
+                      "debugedit-try-debian-i386",
+                      "debugedit-try-debian-armhf",
+                      "debugedit-try-fedora-s390x",
+                      "debugedit-try-debian-ppc64",
+                      "debugedit-try-fedora-ppc64le",
+                      "debugedit-try-ubuntu-riscv",
+                      "debugedit-try-opensusetw-x86_64",
+                      "debugedit-try-opensuseleap-x86_64"])
+c['schedulers'].append(debugedit_try_scheduler)
+
 # Only trigger scheduler for changes to rust frontend files
 gccrs_files = ["gcc/rust/",
                "gcc/testsuite/rust/",
@@ -1826,6 +1851,13 @@ debugedit_alma_x86_64_builder = util.BuilderConfig(
         factory=debugedit_factory)
 c['builders'].append(debugedit_alma_x86_64_builder)
 
+debugedit_try_alma_x86_64_builder = util.BuilderConfig(
+        name="debugedit-try-alma-x86_64",
+        workernames=["alma-x86_64"],
+        tags=["debugedit-try", "alma", "x86_64"],
+        factory=debugedit_factory)
+c['builders'].append(debugedit_try_alma_x86_64_builder)
+
 #debugedit_debian_arm64_builder = util.BuilderConfig(
 #        name="debugedit-debian-arm64",
 #        workernames=["debian-arm64"],
@@ -1834,6 +1866,14 @@ c['builders'].append(debugedit_alma_x86_64_builder)
 #        factory=debugedit_factory)
 #c['builders'].append(debugedit_debian_arm64_builder)
 
+#debugedit_try_debian_arm64_builder = util.BuilderConfig(
+#        name="debugedit-try-debian-arm64",
+#        workernames=["debian-arm64"],
+#        tags=["debugedit-try", "debian", "arm64"],
+#        collapseRequests=True,
+#        factory=debugedit_factory)
+#c['builders'].append(debugedit_try_debian_arm64_builder)
+
 debugedit_fedora_arm64_builder = util.BuilderConfig(
         name="debugedit-fedora-arm64",
         workernames=["fedora-arm64"],
@@ -1841,6 +1881,13 @@ debugedit_fedora_arm64_builder = util.BuilderConfig(
         factory=debugedit_factory)
 c['builders'].append(debugedit_fedora_arm64_builder)
 
+debugedit_try_fedora_arm64_builder = util.BuilderConfig(
+        name="debugedit-try-fedora-arm64",
+        workernames=["fedora-arm64"],
+        tags=["debugedit-try", "fedora", "arm64"],
+        factory=debugedit_factory)
+c['builders'].append(debugedit_try_fedora_arm64_builder)
+
 debugedit_fedora_x86_64_builder = util.BuilderConfig(
         name="debugedit-fedora-x86_64",
 	properties={'container-file':
@@ -1850,6 +1897,15 @@ debugedit_fedora_x86_64_builder = util.BuilderConfig(
         factory=debugedit_factory)
 c['builders'].append(debugedit_fedora_x86_64_builder)
 
+debugedit_try_fedora_x86_64_builder = util.BuilderConfig(
+        name="debugedit-try-fedora-x86_64",
+	properties={'container-file':
+		    readContainerFile('fedora-latest')},
+	workernames=vm_workers,
+        tags=["debugedit-try", "fedora", "x86_64"],
+        factory=debugedit_factory)
+c['builders'].append(debugedit_try_fedora_x86_64_builder)
+
 debugedit_fedora_clang_x86_64_builder = util.BuilderConfig(
         name="debugedit-fedora-clang-x86_64",
 	properties={'container-file':
@@ -1859,6 +1915,15 @@ debugedit_fedora_clang_x86_64_builder = util.BuilderConfig(
         factory=debugedit_factory_clang)
 c['builders'].append(debugedit_fedora_clang_x86_64_builder)
 
+debugedit_try_fedora_clang_x86_64_builder = util.BuilderConfig(
+        name="debugedit-try-fedora-clang-x86_64",
+	properties={'container-file':
+		    readContainerFile('fedora-latest')},
+	workernames=vm_workers,
+        tags=["debugedit-try", "fedora", "clang", "x86_64"],
+        factory=debugedit_factory_clang)
+c['builders'].append(debugedit_try_fedora_clang_x86_64_builder)
+
 debugedit_debian_amd64_builder = util.BuilderConfig(
         name="debugedit-debian-amd64",
 	properties={'container-file':
@@ -1868,6 +1933,15 @@ debugedit_debian_amd64_builder = util.BuilderConfig(
         factory=debugedit_factory)
 c['builders'].append(debugedit_debian_amd64_builder)
 
+debugedit_try_debian_amd64_builder = util.BuilderConfig(
+        name="debugedit-try-debian-amd64",
+	properties={'container-file':
+		    readContainerFile('debian-stable')},
+	workernames=vm_workers,
+        tags=["debugedit-try", "debian", "x86_64"],
+        factory=debugedit_factory)
+c['builders'].append(debugedit_try_debian_amd64_builder)
+
 debugedit_debian_armhf_builder = util.BuilderConfig(
         name="debugedit-debian-armhf",
         workernames=["debian-armhf"],
@@ -1876,6 +1950,14 @@ debugedit_debian_armhf_builder = util.BuilderConfig(
         factory=debugedit_factory)
 c['builders'].append(debugedit_debian_armhf_builder)
 
+debugedit_try_debian_armhf_builder = util.BuilderConfig(
+        name="debugedit-try-debian-armhf",
+        workernames=["debian-armhf"],
+        tags=["debugedit-try", "debian", "armhf"],
+        collapseRequests=True,
+        factory=debugedit_factory)
+c['builders'].append(debugedit_try_debian_armhf_builder)
+
 debugedit_debian_i386_builder = util.BuilderConfig(
         name="debugedit-debian-i386",
         workernames=debian_i386_workers,
@@ -1883,6 +1965,13 @@ debugedit_debian_i386_builder = util.BuilderConfig(
         factory=debugedit_factory)
 c['builders'].append(debugedit_debian_i386_builder)
 
+debugedit_try_debian_i386_builder = util.BuilderConfig(
+        name="debugedit-try-debian-i386",
+        workernames=debian_i386_workers,
+        tags=["debugedit-try", "debian", "i386"],
+        factory=debugedit_factory)
+c['builders'].append(debugedit_try_debian_i386_builder)
+
 debugedit_fedora_s390x_builder = util.BuilderConfig(
         name="debugedit-fedora-s390x",
         workernames=["fedora-s390x"],
@@ -1891,6 +1980,14 @@ debugedit_fedora_s390x_builder = util.BuilderConfig(
         factory=debugedit_factory)
 c['builders'].append(debugedit_fedora_s390x_builder)
 
+debugedit_try_fedora_s390x_builder = util.BuilderConfig(
+        name="debugedit-try-fedora-s390x",
+        workernames=["fedora-s390x"],
+        tags=["debugedit-try", "fedora", "s390x"],
+        collapseRequests=True,
+        factory=debugedit_factory)
+c['builders'].append(debugedit_try_fedora_s390x_builder)
+
 debugedit_debian_ppc64_builder = util.BuilderConfig(
         name="debugedit-debian-ppc64",
         workernames=["debian-ppc64"],
@@ -1898,6 +1995,13 @@ debugedit_debian_ppc64_builder = util.BuilderConfig(
         factory=debugedit_factory)
 c['builders'].append(debugedit_debian_ppc64_builder)
 
+debugedit_try_debian_ppc64_builder = util.BuilderConfig(
+        name="debugedit-try-debian-ppc64",
+        workernames=["debian-ppc64"],
+        tags=["debugedit-try", "debian", "ppc64"],
+        factory=debugedit_factory)
+c['builders'].append(debugedit_try_debian_ppc64_builder)
+
 debugedit_fedora_ppc64le_builder = util.BuilderConfig(
         name="debugedit-fedora-ppc64le",
         workernames=["fedora-ppc64le"],
@@ -1906,6 +2010,14 @@ debugedit_fedora_ppc64le_builder = util.BuilderConfig(
         factory=debugedit_factory)
 c['builders'].append(debugedit_fedora_ppc64le_builder)
 
+debugedit_try_fedora_ppc64le_builder = util.BuilderConfig(
+        name="debugedit-try-fedora-ppc64le",
+        workernames=["fedora-ppc64le"],
+        tags=["debugedit-try", "fedora", "ppc64le"],
+        collapseRequests=True,
+        factory=debugedit_factory)
+c['builders'].append(debugedit_try_fedora_ppc64le_builder)
+
 debugedit_ubuntu_riscv_builder = util.BuilderConfig(
         name="debugedit-ubuntu-riscv",
         workernames=starfive_workers,
@@ -1914,6 +2026,14 @@ debugedit_ubuntu_riscv_builder = util.BuilderConfig(
         factory=debugedit_factory)
 c['builders'].append(debugedit_ubuntu_riscv_builder)
 
+debugedit_try_ubuntu_riscv_builder = util.BuilderConfig(
+        name="debugedit-try-ubuntu-riscv",
+        workernames=starfive_workers,
+        tags=["debugedit-try", "ubuntu", "riscv"],
+        collapseRequests=True,
+        factory=debugedit_factory)
+c['builders'].append(debugedit_try_ubuntu_riscv_builder)
+
 debugedit_opensusetw_x86_64_builder = util.BuilderConfig(
         name="debugedit-opensusetw-x86_64",
 	properties={'container-file':
@@ -1923,6 +2043,15 @@ debugedit_opensusetw_x86_64_builder = util.BuilderConfig(
         factory=debugedit_factory)
 c['builders'].append(debugedit_opensusetw_x86_64_builder)
 
+debugedit_try_opensusetw_x86_64_builder = util.BuilderConfig(
+        name="debugedit-try-opensusetw-x86_64",
+	properties={'container-file':
+		    readContainerFile('opensuse-tumbleweed')},
+	workernames=vm_workers,
+        tags=["debugedit-try", "opensusetw", "x86_64"],
+        factory=debugedit_factory)
+c['builders'].append(debugedit_try_opensusetw_x86_64_builder)
+
 debugedit_opensuseleap_x86_64_builder = util.BuilderConfig(
         name="debugedit-opensuseleap-x86_64",
 	properties={'container-file':
@@ -1932,6 +2061,15 @@ debugedit_opensuseleap_x86_64_builder = util.BuilderConfig(
         factory=debugedit_factory)
 c['builders'].append(debugedit_opensuseleap_x86_64_builder)
 
+debugedit_try_opensuseleap_x86_64_builder = util.BuilderConfig(
+        name="debugedit-try-opensuseleap-x86_64",
+	properties={'container-file':
+		    readContainerFile('opensuse-leap')},
+	workernames=vm_workers,
+        tags=["debugedit-try", "opensuseleap", "x86_64"],
+        factory=debugedit_factory)
+c['builders'].append(debugedit_try_opensuseleap_x86_64_builder)
+
 #debugedit_rawhide_x86_64_builder = util.BuilderConfig(
 #        name="debugedit-rawhide-x86_64",
 #	properties={'container-file':
@@ -1942,6 +2080,16 @@ c['builders'].append(debugedit_opensuseleap_x86_64_builder)
 #        factory=debugedit_factory)
 #c['builders'].append(debugedit_rawhide_x86_64_builder)
 
+#debugedit_try_rawhide_x86_64_builder = util.BuilderConfig(
+#        name="debugedit-try-rawhide-x86_64",
+#	properties={'container-file':
+#		    readContainerFile('fedora-rawhide')},
+#	workernames=vm_workers,
+#        tags=["debugedit-try", "fedora", "x86_64"],
+#        collapseRequests=True,
+#        factory=debugedit_factory)
+#c['builders'].append(debugedit_try_rawhide_x86_64_builder)
+
 #debugedit_debian_testing_x86_64_builder = util.BuilderConfig(
 #        name="debugedit-debian-testing-x86_64",
 #	properties={'container-file':
@@ -1952,6 +2100,16 @@ c['builders'].append(debugedit_opensuseleap_x86_64_builder)
 #        factory=debugedit_factory)
 #c['builders'].append(debugedit_debian_testing_x86_64_builder)
 
+#debugedit_try_debian_testing_x86_64_builder = util.BuilderConfig(
+#        name="debugedit-try-debian-testing-x86_64",
+#	properties={'container-file':
+#		    readContainerFile('debian-testing')},
+#	workernames=vm_workers,
+#        tags=["debugedit-try", "debian", "x86_64"],
+#        collapseRequests=True,
+#        factory=debugedit_factory)
+#c['builders'].append(debugedit_try_debian_testing_x86_64_builder)
+
 debugedit_gentoo_sparc_builder = util.BuilderConfig(
         name="debugedit-gentoo-sparc",
         workernames=sparc_workers,
@@ -1959,6 +2117,13 @@ debugedit_gentoo_sparc_builder = util.BuilderConfig(
         factory=debugedit_factory)
 c['builders'].append(debugedit_gentoo_sparc_builder)
 
+debugedit_try_gentoo_sparc_builder = util.BuilderConfig(
+        name="debugedit-try-gentoo-sparc",
+        workernames=sparc_workers,
+        tags=["debugedit-try", "gentoo", "sparc"],
+        factory=debugedit_factory)
+c['builders'].append(debugedit_try_gentoo_sparc_builder)
+
 # dwz build steps, factory and builders
 
 # Not parallel and special named log files
@@ -5514,6 +5679,15 @@ mn_debugedit_change = reporters.MailNotifier(
         generators=[generator_debugedit_change])
 c['services'].append(mn_debugedit_change)
 
+# Just sent a report to the interested try user (author).
+generator_debugedit_try = reporters.BuildStatusGenerator(
+        tags=["debugedit-try"])
+mn_debugedit_try = reporters.MailNotifier(
+        fromaddr="builder@sourceware.org",
+        sendToInterestedUsers=True,
+        generators=[generator_debugedit_try])
+c['services'].append(mn_debugedit_try)
+
 # Problem report for the whole dwz tagged builder set
 generator_dwz = reporters.BuildSetStatusGenerator(
         mode=('problem',), tags=['dwz'])
-- 
2.47.0


From builder@sourceware.org  Mon Oct 28 18:44:30 2024
From: builder@sourceware.org (builder@sourceware.org)
Date: Mon, 28 Oct 2024 18:44:30 +0000
Subject: =?utf-8?q?=E2=98=A0_Buildbot_=28Sourceware=29=3A_debugedit_-_failed_test_=28failure=29_test_=28failure=29_=28main=29?=
Message-ID: <20241028184430.D32E23858D26@sourceware.org>

A new failure has been detected on builder debugedit-alma-x86_64 while building debugedit.

Full details are available at:
    https://builder.sourceware.org/buildbot/#/builders/289/builds/16

Build state: failed test (failure) test (failure)
Revision: c156ae62c3913aa86bd4cd4abda93772747e029f
Worker: alma-x86_64
Build Reason: (unknown)
Blamelist: Morten Linderud <morten@linderud.pw>

Steps:

- 0: worker_preparation ( success )

- 1: set package name ( success )

- 2: git checkout ( success )
    Logs:
        - stdio: https://builder.sourceware.org/buildbot/#/builders/289/builds/16/steps/2/logs/stdio

- 3: autoreconf ( success )
    Logs:
        - stdio: https://builder.sourceware.org/buildbot/#/builders/289/builds/16/steps/3/logs/stdio

- 4: configure ( success )
    Logs:
        - stdio: https://builder.sourceware.org/buildbot/#/builders/289/builds/16/steps/4/logs/stdio
        - config.log: https://builder.sourceware.org/buildbot/#/builders/289/builds/16/steps/4/logs/config_log

- 5: get version ( success )
    Logs:
        - stdio: https://builder.sourceware.org/buildbot/#/builders/289/builds/16/steps/5/logs/stdio
        - property changes: https://builder.sourceware.org/buildbot/#/builders/289/builds/16/steps/5/logs/property_changes

- 6: make ( success )
    Logs:
        - stdio: https://builder.sourceware.org/buildbot/#/builders/289/builds/16/steps/6/logs/stdio

- 7: make check ( failure )
    Logs:
        - stdio: https://builder.sourceware.org/buildbot/#/builders/289/builds/16/steps/7/logs/stdio
        - testsuite.log: https://builder.sourceware.org/buildbot/#/builders/289/builds/16/steps/7/logs/testsuite_log

- 8: make distcheck ( failure )
    Logs:
        - stdio: https://builder.sourceware.org/buildbot/#/builders/289/builds/16/steps/8/logs/stdio
        - testsuite.log: https://builder.sourceware.org/buildbot/#/builders/289/builds/16/steps/8/logs/testsuite_log

- 9: prep ( success )
    Logs:
        - stdio: https://builder.sourceware.org/buildbot/#/builders/289/builds/16/steps/9/logs/stdio

- 10: build bunsen.cpio.gz ( success )
    Logs:
        - stdio: https://builder.sourceware.org/buildbot/#/builders/289/builds/16/steps/10/logs/stdio

- 11: fetch bunsen.cpio.gz ( success )
    Logs:
        - stdio: https://builder.sourceware.org/buildbot/#/builders/289/builds/16/steps/11/logs/stdio

- 12: unpack bunsen.cpio.gz ( success )
    Logs:
        - stdio: https://builder.sourceware.org/buildbot/#/builders/289/builds/16/steps/12/logs/stdio

- 13: pass .bunsen.source.* ( success )
    Logs:
        - stdio: https://builder.sourceware.org/buildbot/#/builders/289/builds/16/steps/13/logs/stdio

- 14: upload to bunsen ( success )
    Logs:
        - stdio: https://builder.sourceware.org/buildbot/#/builders/289/builds/16/steps/14/logs/stdio

- 15: clean up ( success )
    Logs:
        - stdio: https://builder.sourceware.org/buildbot/#/builders/289/builds/16/steps/15/logs/stdio

- 16: make clean ( success )
    Logs:
        - stdio: https://builder.sourceware.org/buildbot/#/builders/289/builds/16/steps/16/logs/stdio


From mark@klomp.org  Tue Oct 29 00:51:52 2024
From: mark@klomp.org (Mark Wielaard)
Date: Tue, 29 Oct 2024 01:51:52 +0100
Subject: [COMMITTED] tests: Old binutils readelf doesn't handle compressed
 debugsections
Message-ID: <20241029005152.1046496-1-mark@klomp.org>

Older versions don't cope correctly with compressed debug sections
https://sourceware.org/bugzilla/show_bug.cgi?id=23919
It is difficult to do a feature check for this, so just do a version
check.
---
 configure.ac       | 19 +++++++++++++++++++
 tests/atlocal.in   |  1 +
 tests/debugedit.at |  5 +++++
 3 files changed, 25 insertions(+)

diff --git a/configure.ac b/configure.ac
index 96922267b7fe..180c59931cf6 100644
--- a/configure.ac
+++ b/configure.ac
@@ -162,6 +162,25 @@ else
 fi
 AC_SUBST([DEBUG_MACRO_FLAG])
 
+# We really need binutils readelf version 2.31 or higher
+# Older versions don't cope correctly with compressed debug sections
+# https://sourceware.org/bugzilla/show_bug.cgi?id=23919
+# It is difficult to do a feature check for this, so just do a version check.
+READELF_STRING=$($READELF --version | head -1)
+# The double [[ and ]] is because of configure.ac being an m4 script.
+READELF_REGEXP='s/GNU readelf[[a-zA-Z() _-]]*\([[1-9]]\)\.\([[0-9]]*\).*/\1\2/'
+READELF_VER=$(echo "$READELF_STRING" | sed -e "$READELF_REGEXP")
+AC_CACHE_CHECK([readelf version for compress tests], ac_cv_readelf_ver, [dnl
+ac_cv_readelf_ver="$READELF_VER"
+])
+if test "$READELF_VER" -ge "231"; then
+  READELF_VERSION_OK="yes"
+else
+  AC_MSG_WARN([$READELF_STRING ($READELF_VER) cannot do compression tests])
+  READELF_VERSION_OK="no"
+fi
+AC_SUBST([READELF_VERSION_OK])
+
 # And generate the output files.
 AC_CONFIG_FILES([Makefile])
 AC_OUTPUT
diff --git a/tests/atlocal.in b/tests/atlocal.in
index d3364d3e9e58..9da28786ba26 100644
--- a/tests/atlocal.in
+++ b/tests/atlocal.in
@@ -10,6 +10,7 @@ CFLAGS=""
 LD="@LD@"
 LDFLAGS=""
 READELF="@READELF@"
+READELF_VERSION_OK="@READELF_VERSION_OK@"
 
 GDWARF_5_FLAG=@GDWARF_5_FLAG@
 GZ_NONE_FLAG=@GZ_NONE_FLAG@
diff --git a/tests/debugedit.at b/tests/debugedit.at
index b125e627546d..8e69c0e60e8a 100644
--- a/tests/debugedit.at
+++ b/tests/debugedit.at
@@ -97,6 +97,7 @@ AT_CLEANUP
 AT_SETUP([debugedit executable (compressed)])
 AT_KEYWORDS([debuginfo] [debugedit])
 AT_SKIP_IF([test -z "$GZ_ZLIB_FLAG"])
+AT_SKIP_IF([test "$READELF_VERSION_OK" = "no"])
 DEBUGEDIT_SETUP([], [$GZ_ZLIB_FLAG])
 
 AT_CHECK([[./foobarbaz.exe]])
@@ -349,6 +350,7 @@ AT_CLEANUP
 AT_SETUP([debugedit .debug_info objects (compressed)])
 AT_KEYWORDS([debuginfo] [debugedit])
 AT_SKIP_IF([test -z "$GZ_ZLIB_FLAG"])
+AT_SKIP_IF([test "$READELF_VERSION_OK" = "no"])
 DEBUGEDIT_SETUP([], [$GZ_ZLIB_FLAG])
 
 AT_DATA([expout],
@@ -396,6 +398,7 @@ AT_CLEANUP
 AT_SETUP([debugedit .debug_info partial (compressed)])
 AT_KEYWORDS([debuginfo] [debugedit])
 AT_SKIP_IF([test -z "$GZ_ZLIB_FLAG"])
+AT_SKIP_IF([test "$READELF_VERSION_OK" = "no"])
 DEBUGEDIT_SETUP([], [$GZ_ZLIB_FLAG])
 
 AT_DATA([expout],
@@ -438,6 +441,7 @@ AT_CLEANUP
 AT_SETUP([debugedit .debug_info exe (compressed)])
 AT_KEYWORDS([debuginfo] [debugedit])
 AT_SKIP_IF([test -z "$GZ_ZLIB_FLAG"])
+AT_SKIP_IF([test "$READELF_VERSION_OK" = "no"])
 DEBUGEDIT_SETUP([], [$GZ_ZLIB_FLAG])
 
 AT_DATA([expout],
@@ -813,6 +817,7 @@ AT_CLEANUP
 AT_SETUP([debugedit .debug_macro exe (compressed)])
 AT_KEYWORDS([debuginfo] [debugedit])
 AT_SKIP_IF([test -z "$GZ_ZLIB_FLAG"])
+AT_SKIP_IF([test "$READELF_VERSION_OK" = "no"])
 DEBUGEDIT_SETUP([$DEBUG_MACRO_FLAG], [$GZ_ZLIB_FLAG])
 
 # We expect 3 for each compile unit.
-- 
2.47.0


From mark@klomp.org  Tue Oct 29 02:34:29 2024
From: mark@klomp.org (Mark Wielaard)
Date: Tue, 29 Oct 2024 03:34:29 +0100
Subject: [COMMITTED] configure: Adjust READELF_REGEXP for OpenSuse
Message-ID: <20241029023429.1055656-1-mark@klomp.org>

Leap readelf verion looks like:
GNU readelf (GNU Binutils; SUSE Linux Enterprise 15) 2.43.1.20240828-150100.7.49
Tumbleweed uses:
GNU readelf (GNU Binutils; openSUSE Tumbleweed) 2.43.1.20240828-2

So also allow ';' and numbers before the actual version.

Signed-off-by: Mark Wielaard <mark@klomp.org>
---
 configure.ac | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/configure.ac b/configure.ac
index 180c59931cf6..1ce40ea0ca23 100644
--- a/configure.ac
+++ b/configure.ac
@@ -168,7 +168,7 @@ AC_SUBST([DEBUG_MACRO_FLAG])
 # It is difficult to do a feature check for this, so just do a version check.
 READELF_STRING=$($READELF --version | head -1)
 # The double [[ and ]] is because of configure.ac being an m4 script.
-READELF_REGEXP='s/GNU readelf[[a-zA-Z() _-]]*\([[1-9]]\)\.\([[0-9]]*\).*/\1\2/'
+READELF_REGEXP='s/GNU readelf[[a-zA-Z0-9(); _-]]*\([[1-9]]\)\.\([[0-9]]*\).*/\1\2/'
 READELF_VER=$(echo "$READELF_STRING" | sed -e "$READELF_REGEXP")
 AC_CACHE_CHECK([readelf version for compress tests], ac_cv_readelf_ver, [dnl
 ac_cv_readelf_ver="$READELF_VER"
-- 
2.47.0


From builder@sourceware.org  Tue Oct 29 02:46:20 2024
From: builder@sourceware.org (builder@sourceware.org)
Date: Tue, 29 Oct 2024 02:46:20 +0000
Subject: =?utf-8?q?=E2=98=BA_Buildbot_=28Sourceware=29=3A_debugedit_-_build_successful_=28main=29?=
Message-ID: <20241029024620.F333F3858D26@sourceware.org>

A restored build has been detected on builder debugedit-alma-x86_64 while building debugedit.

Full details are available at:
    https://builder.sourceware.org/buildbot/#/builders/289/builds/17

Build state: build successful
Revision: cc0f07b0e2b18d5334ba47b7fc1605c75af2a523
Worker: alma-x86_64
Build Reason: (unknown)
Blamelist: Mark Wielaard <mark@klomp.org>, Morten Linderud <morten@linderud.pw>

Steps:

- 0: worker_preparation ( success )

- 1: set package name ( success )

- 2: git checkout ( success )
    Logs:
        - stdio: https://builder.sourceware.org/buildbot/#/builders/289/builds/17/steps/2/logs/stdio

- 3: autoreconf ( success )
    Logs:
        - stdio: https://builder.sourceware.org/buildbot/#/builders/289/builds/17/steps/3/logs/stdio

- 4: configure ( success )
    Logs:
        - stdio: https://builder.sourceware.org/buildbot/#/builders/289/builds/17/steps/4/logs/stdio
        - config.log: https://builder.sourceware.org/buildbot/#/builders/289/builds/17/steps/4/logs/config_log

- 5: get version ( success )
    Logs:
        - stdio: https://builder.sourceware.org/buildbot/#/builders/289/builds/17/steps/5/logs/stdio
        - property changes: https://builder.sourceware.org/buildbot/#/builders/289/builds/17/steps/5/logs/property_changes

- 6: make ( success )
    Logs:
        - stdio: https://builder.sourceware.org/buildbot/#/builders/289/builds/17/steps/6/logs/stdio

- 7: make check ( success )
    Logs:
        - stdio: https://builder.sourceware.org/buildbot/#/builders/289/builds/17/steps/7/logs/stdio
        - testsuite.log: https://builder.sourceware.org/buildbot/#/builders/289/builds/17/steps/7/logs/testsuite_log

- 8: make distcheck ( warnings )
    Logs:
        - stdio: https://builder.sourceware.org/buildbot/#/builders/289/builds/17/steps/8/logs/stdio
        - testsuite.log: https://builder.sourceware.org/buildbot/#/builders/289/builds/17/steps/8/logs/testsuite_log
        - warnings (1): https://builder.sourceware.org/buildbot/#/builders/289/builds/17/steps/8/logs/warnings__1_

- 9: prep ( success )
    Logs:
        - stdio: https://builder.sourceware.org/buildbot/#/builders/289/builds/17/steps/9/logs/stdio

- 10: build bunsen.cpio.gz ( success )
    Logs:
        - stdio: https://builder.sourceware.org/buildbot/#/builders/289/builds/17/steps/10/logs/stdio

- 11: fetch bunsen.cpio.gz ( success )
    Logs:
        - stdio: https://builder.sourceware.org/buildbot/#/builders/289/builds/17/steps/11/logs/stdio

- 12: unpack bunsen.cpio.gz ( success )
    Logs:
        - stdio: https://builder.sourceware.org/buildbot/#/builders/289/builds/17/steps/12/logs/stdio

- 13: pass .bunsen.source.* ( success )
    Logs:
        - stdio: https://builder.sourceware.org/buildbot/#/builders/289/builds/17/steps/13/logs/stdio

- 14: upload to bunsen ( success )
    Logs:
        - stdio: https://builder.sourceware.org/buildbot/#/builders/289/builds/17/steps/14/logs/stdio

- 15: clean up ( success )
    Logs:
        - stdio: https://builder.sourceware.org/buildbot/#/builders/289/builds/17/steps/15/logs/stdio

- 16: make clean ( success )
    Logs:
        - stdio: https://builder.sourceware.org/buildbot/#/builders/289/builds/17/steps/16/logs/stdio


From mark@klomp.org  Tue Oct 29 15:28:11 2024
From: mark@klomp.org (Mark Wielaard)
Date: Tue, 29 Oct 2024 16:28:11 +0100
Subject: [COMMITTED] configure: Set version to 5.1
Message-ID: <20241029152811.3358344-1-mark@klomp.org>

Signed-off-by: Mark Wielaard <mark@klomp.org>
---
 configure.ac | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/configure.ac b/configure.ac
index 1ce40ea0ca23..a5a6e28656a6 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,7 +1,7 @@
 #                                               -*- Autoconf -*-
 # Process this file with autoconf to produce a configure script.
 
-# Copyright (C) 2021 Mark J. Wielaard <mark@klomp.org>
+# Copyright (C) 2021, 2024 Mark J. Wielaard <mark@klomp.org>
 #
 # This program is free software: you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -17,7 +17,7 @@
 # along with this program.  If not, see <https://www.gnu.org/licenses/>.
 
 AC_PREREQ([2.69])
-AC_INIT([debugedit], [5.0], [debugedit@sourceware.org])
+AC_INIT([debugedit], [5.1], [debugedit@sourceware.org])
 AC_CONFIG_SRCDIR([tools/debugedit.c])
 AC_CONFIG_HEADERS([config.h])
 
-- 
2.47.0


From mark@klomp.org  Tue Oct 29 16:22:38 2024
From: mark@klomp.org (Mark Wielaard)
Date: Tue, 29 Oct 2024 17:22:38 +0100
Subject: debugedit 5.1 released
Message-ID: <6e1b9065bc299153208e2d41140b78e81c1890b5.camel@klomp.org>

DEBUGEDIT 5.1 - https://sourceware.org/debugedit

A new release of debugedit is available at
https://sourceware.org/pub/debugedit/5.1/

* NEW *

- Architecture support for hppa and loongarch
- Switch to xxhash for buildid recomputation (much faster!)
- find-debuginfo supports -v,--verbose and -q,--quiet
- find-debuginfo passes -j down to dwz
- debugedit now handles Handle DWARF5 DW_UT_type (Unit type 2)
  in ET_EXE/DYN, DW_MACRO_{define,undef}_strx, .debug_str_offsets
  (DW_FORM_strx)
- debugedit handles compressed DWARF debug sections

* GIT SHORTLOG *

Allan McRae (1):
  Fix -u option

Denys Vlasenko (2):
  find-debuginfo: remove duplicate filenames when creating debugsources.list
  find-debuginfo: Add -v,--verbose for per file messages

Frank Ch. Eigler (1):
  debugedit: switch to xxhash for buildid recomputation

Kalev Lember (1):
  find-debuginfo: Pass -j down to dwz

Keith Seitz (1):
  find-debuginfo.sh: Exit with real exit status in parallel jobs

Mark Wielaard (30):
  tests: Handle zero directory entry in .debug_line DWARF5 debugedit.at
  find-debuginfo.sh: Remove bogus shift after --dwz-single-file-mode
  debugedit: Use original shdr sh_type to check for NOBITS
  debugedit: Handle hppa EM_PARISC and R_PARISC_DIR32
  debugedit: Guard against NULL names returned by by strptr
  debugedit: Use standard libelf elf_strptr
  debugedit: Skip calling edit_dwarf2 if not rewriting and/or listing source
  configure.ac: Use AC_LINK_IFELSE for -gz=none check
  configure.ac: Use AC_LANG_PROGRAM for AC_LINK_IFELSE -gz=none check
  configure.ac: Update AC_PROG_CC for autoconf 2.70
  debugedit: Use 'z', not 'Z' as conversion specifier
  debugedit: skip .debug_types tests if compiler doesn't generate section
  debuginfo: check whether compiler needs -fdebug-macro
  debugedit: Simplify and extend .debug_line tests
  find-debuginfo: Prefix install_dir to PATH
  Always run cpio with --quiet
  debugedit: Fix missing space in --help output
  debugedit: Add support for .debug_str_offsets (DW_FORM_strx)
  debugedit: Only write the ELF file when updating strings or build-id
  .gitignore: Add config.guess and config.sub
  Make relocation reading explicit
  Simplify update_rela_data by checking rel_updated
  Only process one file at a time in tests with binutils readelf
  debug_str_offsets header version and padding are 2 bytes, not 4 bytes
  debugedit: Track active CU
  debugedit: Handle DW_MACRO_{define,undef}_strx
  debugedit: Handle DWARF5 DW_UT_type (Unit type 2) in ET_EXE/DYN
  tests: Old binutils readelf doesn't handle compressed debugsections
  configure: Adjust READELF_REGEXP for OpenSuse
  configure: Set version to 5.1

Morten Linderud (1):
  debugedit: decompress (and recompress) DWARF sections

Nikita Popov (1):
  Optimize do_read_32_relocated using binary search

Prarit Bhargava (1):
  scripts/find-debuginfo.in: Add -q|--quiet

Sam James (3):
  tools: sepdebugcrcfix: fix build with c23
  tools: sepdebugcrcfix: sort includes
  scripts: find-debuginfo: mention MiniDebugInfo for -m

Sergei Trofimovich (1):
  use $READELF, not readelf

Violet Purcell (1):
  sepdebugcrcfix: Do not use LFS64 functions

daifan (1):
  debugedit: Add support for loongarch

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: This is a digitally signed message part
URL: <https://sourceware.org/pipermail/debugedit/attachments/20241029/8ee880a3/attachment.sig>

From sourceware-bugzilla@sourceware.org  Tue Oct 29 16:52:13 2024
From: sourceware-bugzilla@sourceware.org (mgorny at gentoo dot org)
Date: Tue, 29 Oct 2024 16:52:13 +0000
Subject: [Bug debugedit/32321] New: Bashisms in test suite (5.1 release)
Message-ID: <bug-32321-13298@http.sourceware.org/bugzilla/>

https://sourceware.org/bugzilla/show_bug.cgi?id=32321

            Bug ID: 32321
           Summary: Bashisms in test suite (5.1 release)
           Product: debugedit
           Version: unspecified
            Status: NEW
          Severity: normal
          Priority: P2
         Component: debugedit
          Assignee: unassigned at sourceware dot org
          Reporter: mgorny at gentoo dot org
                CC: debugedit at sourceware dot org
  Target Milestone: ---

When running the test suite of debugedit 5.1 release, I'm getting the following
failure (from testsuite.log):

```
## ---------------------- ##
## Detailed failed tests. ##
## ---------------------- ##

#                             -*- compilation -*-
35. debugedit.at:888: testing debugedit build-id recompute ...
./debugedit.at:894: $READELF -n main | grep Build.ID: | awk '{print $3}'
stderr:
stdout:
a36cda9a8297933830fbdc93cd5ac7a971d9ea10
./debugedit.at:896: expr "$bid" : '[0-9a-f]*'
stdout:
40
./debugedit.at:899: debugedit -i -s deadbeef main
stdout:
af3fd78b4368fd3ca887b5898fce7e7b71d9ea10
./debugedit.at:901: expr "$bid2a" : '[0-9a-f]*'
stdout:
40
./debugedit.at:902: test "$bid" != "$bid2a"
./debugedit.at:905: $READELF -n main | grep Build.ID: | awk '{print $3}'
stderr:
stdout:
af3fd78b4368fd3ca887b5898fce7e7b71d9ea10
./debugedit.at:907: expr "$bid2b" : '[0-9a-f]*'
stdout:
40
./debugedit.at:908: test "$bid2a" == "$bid2b"
--- /dev/null   2024-10-29 06:16:10.049924004 +0100
+++
/tmp/portage/dev-util/debugedit-5.1/work/debugedit-5.1/tests/testsuite.dir/at-groups/35/stderr
     2024-10-29 17:46:02.610089180 +0100
@@ -0,0 +1 @@
+./testsuite: 114: test: af3fd78b4368fd3ca887b5898fce7e7b71d9ea10: unexpected
operator
./debugedit.at:908: exit code was 2, expected 0
35. debugedit.at:888: 35. debugedit build-id recompute (debugedit.at:888):
FAILED (debugedit.at:908)
```

The problem is that "==" test operator is a bashism, and doesn't work in
non-bash shells.

I can confirm that replacing '==' with '=' fixes the test, i.e.:

sed -i -e '/test/s:==:=:' tests/debugedit.at

-- 
You are receiving this mail because:
You are on the CC list for the bug.

From sourceware-bugzilla@sourceware.org  Wed Oct 30 11:08:59 2024
From: sourceware-bugzilla@sourceware.org (mark at klomp dot org)
Date: Wed, 30 Oct 2024 11:08:59 +0000
Subject: [Bug debugedit/32321] Bashisms in test suite (5.1 release)
In-Reply-To: <bug-32321-13298@http.sourceware.org/bugzilla/>
References: <bug-32321-13298@http.sourceware.org/bugzilla/>
Message-ID: <bug-32321-13298-mxS25wSKca@http.sourceware.org/bugzilla/>

https://sourceware.org/bugzilla/show_bug.cgi?id=32321

Mark Wielaard <mark at klomp dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
                 CC|                            |mark at klomp dot org
             Status|NEW                         |RESOLVED

--- Comment #1 from Mark Wielaard <mark at klomp dot org> ---
Thanks, fixed as:

commit 5c8d35b9164d07a5294810bcc128f77f9f419a16
Author: Mark Wielaard <mark@klomp.org>
Date:   Wed Oct 30 12:06:02 2024 +0100

    tests/debugedit.at: Remove bashisms

    The "==" test operator is a bashism, and doesn't work in non-bash
    shells.

    https://sourceware.org/bugzilla/show_bug.cgi?id=32321

    Reported-by: Micha? G?rny <mgorny@gentoo.org>
    Signed-off-by: Mark Wielaard <mark@klomp.org>

-- 
You are receiving this mail because:
You are on the CC list for the bug.

From sourceware-bugzilla@sourceware.org  Wed Oct 30 13:10:10 2024
From: sourceware-bugzilla@sourceware.org (laokz at foxmail dot com)
Date: Wed, 30 Oct 2024 13:10:10 +0000
Subject: [Bug debugedit/31653] RISC-V: readelf fails to apply
 R_RISCV_SET/SUB_ULEB128 relocations: [debugedit 5.0] testsuite: 10 11 19 23
 failed
In-Reply-To: <bug-31653-13298@http.sourceware.org/bugzilla/>
References: <bug-31653-13298@http.sourceware.org/bugzilla/>
Message-ID: <bug-31653-13298-KgGMaNGgoF@http.sourceware.org/bugzilla/>

https://sourceware.org/bugzilla/show_bug.cgi?id=31653

laokz <laokz at foxmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |laokz at foxmail dot com

--- Comment #2 from laokz <laokz at foxmail dot com> ---
(In reply to Mark Wielaard from comment #1)
> I am not seeing this with gcc 13.2.0 and binutils 2.41 as used in the
> buildbot:
> https://builder.sourceware.org/buildbot/#/builders/debugedit-ubuntu-riscv
> 
> What (gcc?) generates these new relocations?
> 
> Could we get rid of this by grepping out the Warnings?

Sorry for the late response. The issue produced with gcc-12.3, binutils-2.41.
Surely we could get rid of it by grepping out the warnings.

When compiled the tests, we added -O2 option. Without -O2, all tests passed and
no R_RISCV_SET/SUB_ULEB128 generated. It seems that gcc/binutils do support
generating these relocs but readelf doesn't support applying them yet.
Reproduce steps:

0. platform: openSUSE Tumbleweed 20241029 - Kernel 6.11.5-1-default, riscv qemu
vm, gcc-14.2.1, binutils-2.43.1.20240828-2
1. echo "int main(){}" >z.c
2. gcc -g -O2 z.c
3. readelf -Wr z.o|grep 128                                                     
0000000000000015  0000001f0000003c R_RISCV_SET_ULEB128    0000000000000004
.LFE0 + 0                                                                       
0000000000000015  0000001e0000003d R_RISCV_SUB_ULEB128    0000000000000000
.LFB0 + 0
4. readelf --debug-dump=info z.o                                          
readelf: Warning: unable to apply unsupported reloc type 60 to section
.debug_rnglists                                                                 
readelf: Warning: unable to apply unsupported reloc type 61 to section
.debug_rnglists
...

This might not a BUG to debugedit. But if there some information in debugedit,
it might be helpful. Thanks.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

