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