rpm/0012-generateBuildIDs-Don-t-warn-or-error-for-object-file.patch

53 lines
1.9 KiB
Diff
Raw Normal View History

From bbeaacd32e74b11264082407e520438373527740 Mon Sep 17 00:00:00 2001
From: Mark Wielaard <mark@klomp.org>
Date: Thu, 9 Mar 2017 09:30:17 +0100
Subject: [PATCH] generateBuildIDs: Don't warn or error for object files
without build-id.
Only loadable ELF images (executables, shared libraries, kernel modules)
should have build-ids. So don't warn or error out when an object file is
found without one.
Signed-off-by: Mark Wielaard <mark@klomp.org>
---
build/files.c | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/build/files.c b/build/files.c
index cbcc0a9..26f53bd 100644
--- a/build/files.c
+++ b/build/files.c
@@ -1709,8 +1709,10 @@ static int generateBuildIDs(FileList fl)
if (lstat(flp->diskPath, &sbuf) == 0 && S_ISREG (sbuf.st_mode)) {
int fd = open (flp->diskPath, O_RDONLY);
if (fd >= 0) {
+ GElf_Ehdr ehdr;
Elf *elf = elf_begin (fd, ELF_C_READ, NULL);
- if (elf != NULL && elf_kind(elf) == ELF_K_ELF) {
+ if (elf != NULL && elf_kind(elf) == ELF_K_ELF
+ && gelf_getehdr(elf, &ehdr) != NULL) {
const void *build_id;
ssize_t len = dwelf_elf_gnu_build_id (elf, &build_id);
/* len == -1 means error. Zero means no
@@ -1759,9 +1761,14 @@ static int generateBuildIDs(FileList fl)
_("error reading build-id in %s: %s\n"),
flp->diskPath, elf_errmsg (-1));
} else if (len == 0) {
- rpmlog(terminate ? RPMLOG_ERR : RPMLOG_WARNING,
- _("Missing build-id in %s\n"),
- flp->diskPath);
+ /* Only ET_EXEC, ET_DYN or kernel modules
+ have build-ids. */
+ if (ehdr.e_type == ET_EXEC || ehdr.e_type == ET_DYN
+ || (ehdr.e_type == ET_REL
+ && rpmFileHasSuffix (flp->diskPath, ".ko")))
+ rpmlog(terminate ? RPMLOG_ERR : RPMLOG_WARNING,
+ _("Missing build-id in %s\n"),
+ flp->diskPath);
} else {
rpmlog(terminate ? RPMLOG_ERR : RPMLOG_WARNING,
(len < 16
--
1.8.3.1