diff options
author | Mark Wielaard <mark@klomp.org> | 2017-03-09 22:13:01 +0100 |
---|---|---|
committer | Panu Matilainen <pmatilai@redhat.com> | 2017-03-10 08:27:50 +0200 |
commit | 5bd77379eee167fbdb8d139dc9ab2da74f2a544f (patch) | |
tree | 94034e7d7de775170dd5f2418acdcc9009c46bad | |
parent | cb3dc0b43bd9a119196a527504d03d57d0785092 (diff) | |
download | rpm-5bd77379eee167fbdb8d139dc9ab2da74f2a544f.tar.gz |
generateBuildIDs: Fix error handling.
commit e6bdf7 made it so that we don't give a warning or error message
for non-kernel ET_REL object files with missing or bad build-ids. But
we still (unintentionally) failed generateBuildIDs which made us skip
generating the cpioList causing an obscure failure message.
Move the sanity check earlier so we don't process such object files at
all. And if there is any real error from generateBuildIDs give a clear
error message and explicitly set processingFailed.
Signed-off-by: Mark Wielaard <mark@klomp.org>
-rw-r--r-- | build/files.c | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/build/files.c b/build/files.c index 26f53bdc3..387284462 100644 --- a/build/files.c +++ b/build/files.c @@ -1709,10 +1709,16 @@ 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) { + /* Only real ELF files, that are ET_EXEC, ET_DYN or + kernel modules (ET_REL files with names ending in .ko) + should have build-ids. */ GElf_Ehdr ehdr; Elf *elf = elf_begin (fd, ELF_C_READ, NULL); if (elf != NULL && elf_kind(elf) == ELF_K_ELF - && gelf_getehdr(elf, &ehdr) != NULL) { + && gelf_getehdr(elf, &ehdr) != NULL + && (ehdr.e_type == ET_EXEC || ehdr.e_type == ET_DYN + || (ehdr.e_type == ET_REL + && rpmFileHasSuffix (flp->diskPath, ".ko")))) { const void *build_id; ssize_t len = dwelf_elf_gnu_build_id (elf, &build_id); /* len == -1 means error. Zero means no @@ -1761,11 +1767,6 @@ static int generateBuildIDs(FileList fl) _("error reading build-id in %s: %s\n"), flp->diskPath, elf_errmsg (-1)); } else if (len == 0) { - /* 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); @@ -2379,8 +2380,11 @@ static rpmRC processPackageFiles(rpmSpec spec, rpmBuildPkgFlags pkgFlags, goto exit; #if HAVE_LIBDW - if (generateBuildIDs (&fl) != 0) + if (generateBuildIDs (&fl) != 0) { + rpmlog(RPMLOG_ERR, _("Generating build-id links failed\n")); + fl.processingFailed = 1; goto exit; + } #endif /* Verify that file attributes scope over hardlinks correctly. */ |