alexk / rpms / rpm

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