Resolves: #RHEL-15924
Routine Rebase of elfutils for 8.10

- Upgrade to upstream elfutils 0.190
- Add eu-srcfiles
- Drop upstreamed patches
  elfutils-0.189-debuginfod_config_cache-double-close.patch
  elfutils-0.189-elf_getdata_rawchunk.patch
  elfutils-0.189-elfcompress.patch
- Only package debuginfod-client-config.7 manpage for debuginfod-client
This commit is contained in:
Mark Wielaard 2023-11-03 21:11:40 +01:00
parent bd9cede034
commit e8db1ffae1
6 changed files with 14 additions and 402 deletions

1
.gitignore vendored
View File

@ -1,3 +1,4 @@
SOURCES/elfutils-0.188.tar.bz2 SOURCES/elfutils-0.188.tar.bz2
/elfutils-0.188.tar.bz2 /elfutils-0.188.tar.bz2
/elfutils-0.189.tar.bz2 /elfutils-0.189.tar.bz2
/elfutils-0.190.tar.bz2

View File

@ -1,73 +0,0 @@
diff --git a/debuginfod/debuginfod-client.c b/debuginfod/debuginfod-client.c
index ef4d47e3..d92d8d62 100644
--- a/debuginfod/debuginfod-client.c
+++ b/debuginfod/debuginfod-client.c
@@ -248,7 +248,7 @@ debuginfod_write_callback (char *ptr, size_t size, size_t nmemb, void *data)
/* handle config file read and write */
static int
-debuginfod_config_cache(char *config_path,
+debuginfod_config_cache(debuginfod_client *c, char *config_path,
long cache_config_default_s,
struct stat *st)
{
@@ -277,17 +277,27 @@ debuginfod_config_cache(char *config_path,
}
long cache_config;
+ /* PR29696 - NB: When using fdopen, the file descriptor is NOT
+ dup'ed and will be closed when the stream is closed. Manually
+ closing fd after fclose is called will lead to a race condition
+ where, if reused, the file descriptor will compete for its
+ regular use before being incorrectly closed here. */
FILE *config_file = fdopen(fd, "r");
if (config_file)
{
if (fscanf(config_file, "%ld", &cache_config) != 1)
- cache_config = cache_config_default_s;
- fclose(config_file);
+ cache_config = cache_config_default_s;
+ if (0 != fclose (config_file) && c->verbose_fd >= 0)
+ dprintf (c->verbose_fd, "fclose failed with %s (err=%d)\n",
+ strerror (errno), errno);
}
else
- cache_config = cache_config_default_s;
-
- close (fd);
+ {
+ cache_config = cache_config_default_s;
+ if (0 != close (fd) && c->verbose_fd >= 0)
+ dprintf (c->verbose_fd, "close failed with %s (err=%d)\n",
+ strerror (errno), errno);
+ }
return cache_config;
}
@@ -303,7 +313,7 @@ debuginfod_clean_cache(debuginfod_client *c,
struct stat st;
/* Create new interval file. */
- rc = debuginfod_config_cache(interval_path,
+ rc = debuginfod_config_cache(c, interval_path,
cache_clean_default_interval_s, &st);
if (rc < 0)
return rc;
@@ -320,7 +330,7 @@ debuginfod_clean_cache(debuginfod_client *c,
utime (interval_path, NULL);
/* Read max unused age value from config file. */
- rc = debuginfod_config_cache(max_unused_path,
+ rc = debuginfod_config_cache(c, max_unused_path,
cache_default_max_unused_age_s, &st);
if (rc < 0)
return rc;
@@ -1110,7 +1135,7 @@ debuginfod_query_server (debuginfod_client *c,
close(fd); /* no need to hold onto the negative-hit file descriptor */
- rc = debuginfod_config_cache(cache_miss_path,
+ rc = debuginfod_config_cache(c, cache_miss_path,
cache_miss_default_s, &st);
if (rc < 0)
goto out;

View File

@ -1,224 +0,0 @@
From 3aca5b5f1f1617db2220022d9061dcaf129e54c4 Mon Sep 17 00:00:00 2001
From: Mark Wielaard <mark@klomp.org>
Date: Wed, 21 Jun 2023 18:05:12 +0200
Subject: [PATCH] libelf: Replace list of elf_getdata_rawchunk results with a
tree
elf_getdata_rawchunks did a linear search to see if a chunk was
already fetched. Replace this list with a binary search tree to make
lookup faster when a lot of Elf_Data_Chunk were created.
* libelf/libelfP.h (Elf_Data_Chunk): Remove next field.
(struct Elf): Change the rawchunks type from Elf_Data_Chunk *
to void *.
* elf_getdata_rawchunk.c (chunk_compare): New static function.
(elf_getdata_rawchunk): Use tsearch instead of a manual linked
list.
* elf_end.c (free_chunk): New static function.
(elf_end): Call tdestroy instead of walking linked list.
Signed-off-by: Mark Wielaard <mark@klomp.org>
---
libelf/elf_end.c | 22 +++++++++-------
libelf/elf_getdata_rawchunk.c | 47 +++++++++++++++++++++++++----------
libelf/libelfP.h | 13 ++++------
3 files changed, 52 insertions(+), 30 deletions(-)
diff --git a/libelf/elf_end.c b/libelf/elf_end.c
index 5c451f36..3e5d4c86 100644
--- a/libelf/elf_end.c
+++ b/libelf/elf_end.c
@@ -1,5 +1,6 @@
/* Free resources associated with Elf descriptor.
Copyright (C) 1998,1999,2000,2001,2002,2004,2005,2007,2015,2016 Red Hat, Inc.
+ Copyright (C) 2023 Mark J. Wielaard <mark@klomp.org>
This file is part of elfutils.
Written by Ulrich Drepper <drepper@redhat.com>, 1998.
@@ -32,12 +33,22 @@
#endif
#include <assert.h>
+#include <search.h>
#include <stddef.h>
#include <stdlib.h>
#include "libelfP.h"
+static void
+free_chunk (void *n)
+{
+ Elf_Data_Chunk *rawchunk = (Elf_Data_Chunk *)n;
+ if (rawchunk->dummy_scn.flags & ELF_F_MALLOCED)
+ free (rawchunk->data.d.d_buf);
+ free (rawchunk);
+}
+
int
elf_end (Elf *elf)
{
@@ -112,20 +123,13 @@ elf_end (Elf *elf)
case ELF_K_ELF:
{
- Elf_Data_Chunk *rawchunks
+ void *rawchunks
= (elf->class == ELFCLASS32
|| (offsetof (struct Elf, state.elf32.rawchunks)
== offsetof (struct Elf, state.elf64.rawchunks))
? elf->state.elf32.rawchunks
: elf->state.elf64.rawchunks);
- while (rawchunks != NULL)
- {
- Elf_Data_Chunk *next = rawchunks->next;
- if (rawchunks->dummy_scn.flags & ELF_F_MALLOCED)
- free (rawchunks->data.d.d_buf);
- free (rawchunks);
- rawchunks = next;
- }
+ tdestroy (rawchunks, free_chunk);
Elf_ScnList *list = (elf->class == ELFCLASS32
|| (offsetof (struct Elf, state.elf32.scns)
diff --git a/libelf/elf_getdata_rawchunk.c b/libelf/elf_getdata_rawchunk.c
index 5a35ccdc..cfd40396 100644
--- a/libelf/elf_getdata_rawchunk.c
+++ b/libelf/elf_getdata_rawchunk.c
@@ -1,6 +1,6 @@
/* Return converted data from raw chunk of ELF file.
Copyright (C) 2007, 2014, 2015 Red Hat, Inc.
- Copyright (C) 2022 Mark J. Wielaard <mark@klomp.org>
+ Copyright (C) 2022, 2023 Mark J. Wielaard <mark@klomp.org>
This file is part of elfutils.
This file is free software; you can redistribute it and/or modify
@@ -33,12 +33,28 @@
#include <assert.h>
#include <errno.h>
+#include <search.h>
#include <stdlib.h>
#include <string.h>
#include "libelfP.h"
#include "common.h"
+static int
+chunk_compare (const void *a, const void *b)
+{
+ Elf_Data_Chunk *da = (Elf_Data_Chunk *)a;
+ Elf_Data_Chunk *db = (Elf_Data_Chunk *)b;
+
+ if (da->offset != db->offset)
+ return da->offset - db->offset;
+
+ if (da->data.d.d_size != db->data.d.d_size)
+ return da->data.d.d_size - db->data.d.d_size;
+
+ return da->data.d.d_type - db->data.d.d_type;
+}
+
Elf_Data *
elf_getdata_rawchunk (Elf *elf, int64_t offset, size_t size, Elf_Type type)
{
@@ -75,19 +91,25 @@ elf_getdata_rawchunk (Elf *elf, int64_t offset, size_t size, Elf_Type type)
rwlock_rdlock (elf->lock);
/* Maybe we already got this chunk? */
- Elf_Data_Chunk *rawchunks = elf->state.elf.rawchunks;
- while (rawchunks != NULL)
+ Elf_Data_Chunk key;
+ key.offset = offset;
+ key.data.d.d_size = size;
+ key.data.d.d_type = type;
+ Elf_Data_Chunk **found = tsearch (&key, &elf->state.elf.rawchunks,
+ &chunk_compare);
+ if (found == NULL)
+ goto nomem;
+
+ /* Existing entry. */
+ if (*found != &key && *found != NULL)
{
- if ((rawchunks->offset == offset || size == 0)
- && rawchunks->data.d.d_size == size
- && rawchunks->data.d.d_type == type)
- {
- result = &rawchunks->data.d;
- goto out;
- }
- rawchunks = rawchunks->next;
+ result = &(*found)->data.d;
+ goto out;
}
+ /* New entry. */
+ *found = NULL;
+
size_t align = __libelf_type_align (elf->class, type);
if (elf->map_address != NULL)
{
@@ -189,8 +211,7 @@ elf_getdata_rawchunk (Elf *elf, int64_t offset, size_t size, Elf_Type type)
rwlock_unlock (elf->lock);
rwlock_wrlock (elf->lock);
- chunk->next = elf->state.elf.rawchunks;
- elf->state.elf.rawchunks = chunk;
+ *found = chunk;
result = &chunk->data.d;
out:
diff --git a/libelf/libelfP.h b/libelf/libelfP.h
index 6624f38a..d3c241e5 100644
--- a/libelf/libelfP.h
+++ b/libelf/libelfP.h
@@ -1,5 +1,6 @@
/* Internal interfaces for libelf.
Copyright (C) 1998-2010, 2015, 2016 Red Hat, Inc.
+ Copyright (C) 2023 Mark J. Wielaard <mark@klomp.org>
This file is part of elfutils.
Contributed by Ulrich Drepper <drepper@redhat.com>, 1998.
@@ -262,11 +263,7 @@ typedef struct Elf_ScnList
typedef struct Elf_Data_Chunk
{
Elf_Data_Scn data;
- union
- {
- Elf_Scn dummy_scn;
- struct Elf_Data_Chunk *next;
- };
+ Elf_Scn dummy_scn;
int64_t offset; /* The original raw offset in the Elf image. */
} Elf_Data_Chunk;
@@ -324,7 +321,7 @@ struct Elf
Elf_ScnList *scns_last; /* Last element in the section list.
If NULL the data has not yet been
read from the file. */
- Elf_Data_Chunk *rawchunks; /* List of elf_getdata_rawchunk results. */
+ void *rawchunks; /* Tree of elf_getdata_rawchunk results. */
unsigned int scnincr; /* Number of sections allocate the last
time. */
int ehdr_flags; /* Flags (dirty) for ELF header. */
@@ -343,7 +340,7 @@ struct Elf
Elf_ScnList *scns_last; /* Last element in the section list.
If NULL the data has not yet been
read from the file. */
- Elf_Data_Chunk *rawchunks; /* List of elf_getdata_rawchunk results. */
+ void *rawchunks; /* Tree of elf_getdata_rawchunk results. */
unsigned int scnincr; /* Number of sections allocate the last
time. */
int ehdr_flags; /* Flags (dirty) for ELF header. */
@@ -368,7 +365,7 @@ struct Elf
Elf_ScnList *scns_last; /* Last element in the section list.
If NULL the data has not yet been
read from the file. */
- Elf_Data_Chunk *rawchunks; /* List of elf_getdata_rawchunk results. */
+ void *rawchunks; /* Tree of elf_getdata_rawchunk results. */
unsigned int scnincr; /* Number of sections allocate the last
time. */
int ehdr_flags; /* Flags (dirty) for ELF header. */
--
2.40.1

View File

@ -1,95 +0,0 @@
From ef9164520c81ea61efe88777a8ad61bf17a54201 Mon Sep 17 00:00:00 2001
From: Mark Wielaard <mark@klomp.org>
Date: Sat, 22 Apr 2023 01:26:17 +0200
Subject: [PATCH] elfcompress: Don't compress if section already compressed
unless forced
Before commit a5b07cdf9 "support ZSTD compression algorithm"
elfcompress would not try to compress a section if it already
had the requested compression type (or was already uncompressed)
unless the --force flag was given. An else if construct was changed
to an if in the commit causing elfcompress to warn (in verbose mode)
but then still try to (re)compress the section.
Add an explicit check so if nothing needs (un)compressing, the file
isn't changed.
The diff looks large, but git diff -b -w is just:
+ if (force || type != schtype)
+ {
if (shdr->sh_type != SHT_NOBITS
&& (shdr->sh_flags & SHF_ALLOC) == 0)
{
@@ -554,6 +556,7 @@ process_file (const char *fname)
printf ("[%zd] %s ignoring %s section\n", ndx, sname,
(shdr->sh_type == SHT_NOBITS ? "no bits" : "allocated"));
}
+ }
Signed-off-by: Mark Wielaard <mark@klomp.org>
---
src/elfcompress.c | 43 +++++++++++++++++++++++--------------------
1 file changed, 23 insertions(+), 20 deletions(-)
diff --git a/src/elfcompress.c b/src/elfcompress.c
index 18ade66f..f771b92a 100644
--- a/src/elfcompress.c
+++ b/src/elfcompress.c
@@ -529,30 +529,33 @@ process_file (const char *fname)
}
}
- if (shdr->sh_type != SHT_NOBITS
- && (shdr->sh_flags & SHF_ALLOC) == 0)
+ if (force || type != schtype)
{
- set_section (sections, ndx);
- /* Check if we might want to change this section name. */
- if (! adjust_names
- && ((type != ZLIB_GNU
- && startswith (sname, ".zdebug"))
- || (type == ZLIB_GNU
- && startswith (sname, ".debug"))))
- adjust_names = true;
-
- /* We need a buffer this large if we change the names. */
- if (adjust_names)
+ if (shdr->sh_type != SHT_NOBITS
+ && (shdr->sh_flags & SHF_ALLOC) == 0)
{
- size_t slen = strlen (sname);
- if (slen > maxnamelen)
- maxnamelen = slen;
+ set_section (sections, ndx);
+ /* Check if we might want to change this section name. */
+ if (! adjust_names
+ && ((type != ZLIB_GNU
+ && startswith (sname, ".zdebug"))
+ || (type == ZLIB_GNU
+ && startswith (sname, ".debug"))))
+ adjust_names = true;
+
+ /* We need a buffer this large if we change the names. */
+ if (adjust_names)
+ {
+ size_t slen = strlen (sname);
+ if (slen > maxnamelen)
+ maxnamelen = slen;
+ }
}
+ else
+ if (verbose >= 0)
+ printf ("[%zd] %s ignoring %s section\n", ndx, sname,
+ (shdr->sh_type == SHT_NOBITS ? "no bits" : "allocated"));
}
- else
- if (verbose >= 0)
- printf ("[%zd] %s ignoring %s section\n", ndx, sname,
- (shdr->sh_type == SHT_NOBITS ? "no bits" : "allocated"));
}
if (shdr->sh_type == SHT_SYMTAB)
--
2.31.1

View File

@ -1,6 +1,6 @@
Name: elfutils Name: elfutils
Version: 0.189 Version: 0.190
%global baserelease 3 %global baserelease 1
Release: %{baserelease}%{?dist} Release: %{baserelease}%{?dist}
URL: http://elfutils.org/ URL: http://elfutils.org/
%global source_url ftp://sourceware.org/pub/elfutils/%{version}/ %global source_url ftp://sourceware.org/pub/elfutils/%{version}/
@ -65,12 +65,6 @@ BuildRequires: gettext-devel
# Patches # Patches
# elfcompress: Don't compress if section already compressed unless forced
Patch1: elfutils-0.189-elfcompress.patch
# libelf: Replace list of elf_getdata_rawchunk results with a tree
Patch2: elfutils-0.189-elf_getdata_rawchunk.patch
# PR29696: Removed secondary fd close in cache config causing race condition
Patch3: elfutils-0.189-debuginfod_config_cache-double-close.patch
%description %description
Elfutils is a collection of utilities, including stack (to show Elfutils is a collection of utilities, including stack (to show
@ -362,6 +356,7 @@ fi
%{_bindir}/eu-ranlib %{_bindir}/eu-ranlib
%{_bindir}/eu-readelf %{_bindir}/eu-readelf
%{_bindir}/eu-size %{_bindir}/eu-size
%{_bindir}/eu-srcfiles
%{_bindir}/eu-stack %{_bindir}/eu-stack
%{_bindir}/eu-strings %{_bindir}/eu-strings
%{_bindir}/eu-strip %{_bindir}/eu-strip
@ -441,7 +436,6 @@ fi
%config(noreplace) %{_sysconfdir}/sysconfig/debuginfod %config(noreplace) %{_sysconfdir}/sysconfig/debuginfod
%{_unitdir}/debuginfod.service %{_unitdir}/debuginfod.service
%{_mandir}/man8/debuginfod*.8* %{_mandir}/man8/debuginfod*.8*
%{_mandir}/man7/debuginfod*.7*
%dir %attr(0700,debuginfod,debuginfod) %{_localstatedir}/cache/debuginfod %dir %attr(0700,debuginfod,debuginfod) %{_localstatedir}/cache/debuginfod
@ -461,6 +455,15 @@ exit 0
%systemd_postun_with_restart debuginfod.service %systemd_postun_with_restart debuginfod.service
%changelog %changelog
* Fri Nov 3 2023 Mark Wielaard <mjw@redhat.com> - 0.190-1
- Upgrade to upstream elfutils 0.190
- Add eu-srcfiles
- Drop upstreamed patches
elfutils-0.189-debuginfod_config_cache-double-close.patch
elfutils-0.189-elf_getdata_rawchunk.patch
elfutils-0.189-elfcompress.patch
- Only package debuginfod-client-config.7 manpage for debuginfod-client
* Wed Jun 28 2023 Mark Wielaard <mjw@redhat.com> - 0.189-3 * Wed Jun 28 2023 Mark Wielaard <mjw@redhat.com> - 0.189-3
- Add elfutils-0.189-elf_getdata_rawchunk.patch - Add elfutils-0.189-elf_getdata_rawchunk.patch
- Add elfutils-0.189-debuginfod_config_cache-double-close.patch - Add elfutils-0.189-debuginfod_config_cache-double-close.patch

View File

@ -1 +1 @@
SHA512 (elfutils-0.189.tar.bz2) = 93a877e34db93e5498581d0ab2d702b08c0d87e4cafd9cec9d6636dfa85a168095c305c11583a5b0fb79374dd93bc8d0e9ce6016e6c172764bcea12861605b71 SHA512 (elfutils-0.190.tar.bz2) = 9c4f5328097e028286c42f29e39dc3d80914b656cdfbbe05b639e91bc787ae8ae64dd4d69a6e317ce30c01648ded10281b86a51e718295f4c589df1225a48102