rpm/0015-generateBuildIDs-Don-t-warn-or-error-for-object-file.patch
Igor Gnatenko 082d5d0331 Track all patches on pagure and git format-patch them since they are cherry-picked
This will give us more correct patches which is easier to rebase and they are taken
from real upstream.

Signed-off-by: Igor Gnatenko <ignatenkobrain@fedoraproject.org>
2017-07-03 14:34:01 +02:00

54 lines
2.0 KiB
Diff

From 590081d625b22b5845015949ecb184989377c928 Mon Sep 17 00:00:00 2001
From: Mark Wielaard <mark@klomp.org>
Date: Thu, 9 Mar 2017 09:34:01 +0100
Subject: [PATCH 15/49] 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>
(cherry picked from commit e6bdf7a807ea5ca30bc467345dd1e07198945603)
---
build/files.c | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/build/files.c b/build/files.c
index ca041764f..274b38c62 100644
--- a/build/files.c
+++ b/build/files.c
@@ -1682,8 +1682,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
@@ -1732,9 +1734,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
--
2.13.2