From 96ccfcaa667db19e1a67190e8c333b0a10018206 Mon Sep 17 00:00:00 2001 From: Thomas Petazzoni Date: Wed, 27 Jul 2022 12:47:51 +0200 Subject: [PATCH] support/scripts/check-host-rpath: send readelf error output to oblivion Somewhere between binutils 2.35 and 2.37, some functionality was added in readelf to parse more DWARF information. Unfortunately, as reported in binutils bug 28981 ("https://sourceware.org/bugzilla/show_bug.cgi?id=28981"), this feature causes a number of fairly scary warnings to be displayed when running readelf on binaries built with Clang, such as the pre-built rustc and rustdoc binaries part of the host-rust-bin package. It looks like this: readelf: /home/thomas/projets/buildroot/output/host/bin/rustc: Warning: Unrecognized form: 0x23 readelf: /home/thomas/projets/buildroot/output/host/bin/rustc: Warning: Bogus end-of-siblings marker detected at offset 2f in .debug_info section readelf: /home/thomas/projets/buildroot/output/host/bin/rustc: Warning: Unrecognized form: 0x22 readelf: /home/thomas/projets/buildroot/output/host/bin/rustc: Warning: Bogus end-of-siblings marker detected at offset 10b in .debug_info section readelf: /home/thomas/projets/buildroot/output/host/bin/rustc: Warning: Bogus end-of-siblings marker detected at offset 10c in .debug_info section readelf: /home/thomas/projets/buildroot/output/host/bin/rustc: Warning: Further warnings about bogus end-of-sibling markers suppressed readelf: /home/thomas/projets/buildroot/output/host/bin/rustc: Warning: Unrecognized form: 0x22 readelf: /home/thomas/projets/buildroot/output/host/bin/rustc: Warning: Unrecognized form: 0x22 readelf: /home/thomas/projets/buildroot/output/host/bin/rustc: Warning: Unrecognized form: 0x22 readelf: /home/thomas/projets/buildroot/output/host/bin/rustc: Warning: Unrecognized form: 0x23 readelf: /home/thomas/projets/buildroot/output/host/bin/rustc: Warning: Unrecognized form: 0x22 readelf: /home/thomas/projets/buildroot/output/host/bin/rustc: Warning: Unrecognized form: 0x23 readelf: /home/thomas/projets/buildroot/output/host/bin/rustc: Warning: Unrecognized form: 0x22 readelf: /home/thomas/projets/buildroot/output/host/bin/rustc: Warning: Unrecognized form: 0x22 readelf: /home/thomas/projets/buildroot/output/host/bin/rustc: Warning: Unrecognized form: 0x22 readelf: /home/thomas/projets/buildroot/output/host/bin/rustc: Warning: Unrecognized form: 0x23 readelf: /home/thomas/projets/buildroot/output/host/bin/rustc: Warning: Unrecognized form: 0x22 readelf: /home/thomas/projets/buildroot/output/host/bin/rustc: Warning: Unrecognized form: 0x23 readelf: /home/thomas/projets/buildroot/output/host/bin/rustc: Warning: Unrecognized form: 0x22 readelf: /home/thomas/projets/buildroot/output/host/bin/rustc: Warning: DIE at offset 0x1da refers to abbreviation number 5827 which does not exist These warnings are caused by the readelf calls done by the support/scripts/check-host-rpath script. The annoying thing is that once host-rust-bin has been installed in $(HOST_DIR), this warning appears after the installation of every single host package, because support/scripts/check-host-rpath rescans all binaries every time. To avoid showing those scary warnings, this commit sends the error output of readelf to /dev/null. Of course, it would be nicer to only filter out those warnings, but filtering the error output without merging the error output into the standard output is tricky, so let's keep things simple. If there is really an error, readelf will abort. Signed-off-by: Thomas Petazzoni Signed-off-by: Yann E. MORIN (cherry picked from commit d353d30deed97bf7953cda379315413ffbb70d89) Signed-off-by: Peter Korsgaard --- support/scripts/check-host-rpath | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/support/scripts/check-host-rpath b/support/scripts/check-host-rpath index b27cb883f3..f36677cc96 100755 --- a/support/scripts/check-host-rpath +++ b/support/scripts/check-host-rpath @@ -61,7 +61,7 @@ elf_needs_rpath() { while read lib; do [ -e "${hostdir}/lib/${lib}" ] && return 0 - done < <( readelf -d "${file}" \ + done < <( readelf -d "${file}" 2>/dev/null \ |sed -r -e '/^.* \(NEEDED\) .*Shared library: \[(.+)\]$/!d;' \ -e 's//\1/;' \ ) @@ -100,7 +100,7 @@ check_elf_has_rpath() { # false. [[ ${dir} =~ "${perpackagedir}/"[^/]+/host/lib ]] && return 0 done - done < <( readelf -d "${file}" \ + done < <( readelf -d "${file}" 2>/dev/null \ |sed -r -e '/.* \(R(UN)?PATH\) +Library r(un)?path: \[(.+)\]$/!d' \ -e 's//\3/;' \ )