Add fix for build-id warnings on object files (#1430587)

This commit is contained in:
Mark Wielaard 2017-03-09 13:18:23 +01:00
parent 5b4d9835cd
commit 74c3099433
2 changed files with 59 additions and 1 deletions

View File

@ -0,0 +1,52 @@
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

View File

@ -29,7 +29,7 @@
Summary: The RPM package management system
Name: rpm
Version: %{rpmver}
Release: %{?snapver:0.%{snapver}.}4%{?dist}
Release: %{?snapver:0.%{snapver}.}5%{?dist}
Group: System Environment/Base
Url: http://www.rpm.org/
Source0: http://rpm.org/releases/%{srcdir}/%{name}-%{srcver}.tar.bz2
@ -82,6 +82,9 @@ Patch258: 0009-Fix-libdw-configure-check.patch
Patch259: 0010-debugedit-Support-String-Line-table-rewriting-for-la.patch
Patch260: 0011-Add-option-to-have-unique-debug-source-dirs-across-v.patch
# debuginfo build-id warn/error fix (#1430587)
Patch261: 0012-generateBuildIDs-Don-t-warn-or-error-for-object-file.patch
# These are not yet upstream
Patch302: rpm-4.7.1-geode-i686.patch
# Probably to be upstreamed in slightly different form
@ -582,6 +585,9 @@ exit 0
%doc doc/librpm/html/*
%changelog
* Thu Mar 09 2017 Mark Wielaard <mjw@redhat.com> - 4.13.0.1-5
- Add fix for build-id warnings on object files (#1430587)
* Wed Mar 08 2017 Panu Matilainen <pmatilai@redhat.com> - 4.13.0.1-4
- Mark Wielaard's backports for debuginfo parallel installation etc (#1427970)