From 1a7230a63a110c091b4a0475c1ed2e8d92e906d8 Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Mar 10 2017 09:07:16 +0000 Subject: Add fixup fix for build-id warnings on object files (#1430587) --- diff --git a/0014-generateBuildIDs-Fix-error-handling.patch b/0014-generateBuildIDs-Fix-error-handling.patch new file mode 100644 index 0000000..9878465 --- /dev/null +++ b/0014-generateBuildIDs-Fix-error-handling.patch @@ -0,0 +1,69 @@ +From 7e053a6d843b141fc6b5a89d050082233ed034d6 Mon Sep 17 00:00:00 2001 +From: Mark Wielaard +Date: Thu, 9 Mar 2017 22:13:01 +0100 +Subject: [PATCH] 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 +--- + build/files.c | 18 +++++++++++------- + 1 file changed, 11 insertions(+), 7 deletions(-) + +diff --git a/build/files.c b/build/files.c +index b19abf2..fef0c69 100644 +--- a/build/files.c ++++ b/build/files.c +@@ -1686,10 +1686,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 +@@ -1738,11 +1744,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); +@@ -2354,8 +2355,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. */ +-- +1.8.3.1 + diff --git a/rpm.spec b/rpm.spec index c9d739c..ff584da 100644 --- a/rpm.spec +++ b/rpm.spec @@ -29,7 +29,7 @@ Summary: The RPM package management system Name: rpm Version: %{rpmver} -Release: %{?snapver:0.%{snapver}.}6%{?dist} +Release: %{?snapver:0.%{snapver}.}7%{?dist} Group: System Environment/Base Url: http://www.rpm.org/ Source0: http://rpm.org/releases/%{srcdir}/%{name}-%{srcver}.tar.bz2 @@ -85,6 +85,7 @@ 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 Patch262: 0013-missing_build_ids_terminate_build.patch +Patch263: 0014-generateBuildIDs-Fix-error-handling.patch # These are not yet upstream Patch302: rpm-4.7.1-geode-i686.patch @@ -586,6 +587,9 @@ exit 0 %doc doc/librpm/html/* %changelog +* Fri Mar 10 2017 Mark Wielaard - 4.13.0.1-7 +- Add fixup fix for build-id warnings on object files (#1430587) + * Thu Mar 09 2017 Mark Wielaard - 4.13.0.1-6 - Add fix for missing_build_ids_terminate_build without __debug_package.