chantra / rpms / rpm

Forked from rpms/rpm 2 years ago
Clone
ed184b
From d48981ad7e36abb3500161d823acf92345c94f5d Mon Sep 17 00:00:00 2001
ed184b
Message-Id: <d48981ad7e36abb3500161d823acf92345c94f5d.1571917458.git.pmatilai@redhat.com>
ed184b
In-Reply-To: <68d383c39cef8d58b80940b13dd132d3f41a03f0.1571917458.git.pmatilai@redhat.com>
ed184b
References: <68d383c39cef8d58b80940b13dd132d3f41a03f0.1571917458.git.pmatilai@redhat.com>
ed184b
From: Panu Matilainen <pmatilai@redhat.com>
ed184b
Date: Tue, 2 Apr 2019 16:07:56 +0300
ed184b
Subject: [PATCH 2/2] Support build-id generation from compressed ELF files
ed184b
 (elfutils >= 0.175)
ed184b
ed184b
Use dwelf_elf_begin() for reading ELF files for build-id generation on
ed184b
versions that have it to support compressed ELF files such as kernel
ed184b
modules (RhBug:1650072,1650074). Note that debugedit still cannot handle
ed184b
compressed files, this is only for build-id generation.
ed184b
---
ed184b
 build/files.c | 4 ++++
ed184b
 configure.ac  | 4 ++++
ed184b
 2 files changed, 8 insertions(+)
ed184b
ed184b
diff --git a/build/files.c b/build/files.c
ed184b
index 3822be3d3..f72a7c866 100644
ed184b
--- a/build/files.c
ed184b
+++ b/build/files.c
ed184b
@@ -1828,7 +1828,11 @@ static int generateBuildIDs(FileList fl, ARGV_t *files)
ed184b
 		   kernel modules (ET_REL files with .modinfo section)
ed184b
 		   should have build-ids. */
ed184b
 		GElf_Ehdr ehdr;
ed184b
+#if HAVE_DWELF_ELF_BEGIN
ed184b
+		Elf *elf = dwelf_elf_begin(fd);
ed184b
+#else
ed184b
 		Elf *elf = elf_begin (fd, ELF_C_READ, NULL);
ed184b
+#endif
ed184b
 		if (elf != NULL && elf_kind(elf) == ELF_K_ELF
ed184b
 		    && gelf_getehdr(elf, &ehdr) != NULL
ed184b
 		    && (ehdr.e_type == ET_EXEC || ehdr.e_type == ET_DYN
ed184b
diff --git a/configure.ac b/configure.ac
ed184b
index 99ce7df32..b2d7ed806 100644
ed184b
--- a/configure.ac
ed184b
+++ b/configure.ac
ed184b
@@ -487,6 +487,10 @@ AS_IF([test "$WITH_LIBELF" = yes],[
ed184b
       # If possible we also want the strtab functions from elfutils 0.167.
ed184b
       # But we can fall back on the (unsupported) ebl alternatives if not.
ed184b
       AC_CHECK_LIB(dw, dwelf_strtab_init, [HAVE_LIBDW_STRTAB=yes])
ed184b
+      # whether libdw supports compressed ELF objects
ed184b
+      AC_CHECK_LIB(dw, dwelf_elf_begin, [
ed184b
+                   AC_DEFINE(HAVE_DWELF_ELF_BEGIN, 1, [Have dwelf_elf_begin?])
ed184b
+      ])
ed184b
     ])
ed184b
   ])
ed184b
 ])
ed184b
-- 
ed184b
2.21.0
ed184b