Skip to content

Commit

Permalink
generateBuildIDs: Don't warn or error for object files without build-id.
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Mark Wielaard authored and pmatilai committed Mar 9, 2017
1 parent f787e69 commit e6bdf7a
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions build/files.c
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit e6bdf7a

Please sign in to comment.