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