From: Thomas Petazzoni via buildroot <buildroot@buildroot.org>
To: "Yann E. MORIN" <yann.morin.1998@free.fr>
Cc: buildroot@buildroot.org,
"Arnout Vandecappelle (Essensium/Mind)" <arnout@mind.be>,
David Laight <David.Laight@aculab.com>
Subject: Re: [Buildroot] [PATCH v2] support/scripts/check-host-libs: add new check on host binaries/libs
Date: Tue, 25 Aug 2026 10:19:44 +0200 [thread overview]
Message-ID: <ao1Pks3_H87lajHF@windsurf> (raw)
In-Reply-To: <ao1E7m-2c4BbHUt9@landeda>
Hello,
On Tue, Aug 25, 2026 at 09:31:58AM +0200, Yann E. MORIN wrote:
> I was wondering why you would not extend check-host-rpath, see my
> tentative, totally untested patch at the end...
>
> Also, check-host-rpath is run after each package install, so it will
> catch executables installed without their dependent libraries, should
> they later be installed.
Ah, good idea. Then maybe check-host-rpath should be renamed into
check-host-bins or something like that, because it would no longer
check just RPATH, but other aspects of host-installed bins and libs?
> > +HOST_DIR=$1
>
> Double-quote variable expansion (shellcheck should have reported that
> one, I think).
I just passed "./utils/docker-run shellcheck" on it, maybe there's
some additional shellcheck options to pass to have stricter checks.
> There is a construct that I tend to use nowadas, which is to use
> true/false, rather than 0/1 or yes/no, because that can be reused
> without a test;
>
> success=true
> for loop; do
> if [ conditiion ]; then
> success=false
> fi
> done
> ${success}
OK, nice.
> And here's a tentative, totally untested patch to introduce that in
> check-host-rpath (indented so that patchwork does not see it):
>
> diff --git a/support/scripts/check-host-rpath b/support/scripts/check-host-rpath
> index 41aa0aa1ed..e1fdf16829 100755
> --- a/support/scripts/check-host-rpath
> +++ b/support/scripts/check-host-rpath
> @@ -21,6 +21,14 @@ main() {
> while read file; do
> is_elf "${file}" || continue
> elf_needs_rpath "${file}" "${hostdir}" || continue
> + missing_libs="$(get_missing_libs "${file}" "${hostdir}")"
> + if [ "${missing_libs}" ]; then
> + ret=1
> + printf "***\n"
> + printf "*** ERROR: package %s uses libs not in HOST_DIR:\n" "${pkg}"
> + # shellcheck disable=SC2086 # we need the word splitting
> + printf ' - %s\n' ${missing_libs}
> + fi
> check_elf_has_rpath "${file}" "${hostdir}" "${perpackagedir}" && continue
> if [ ${ret} -eq 0 ]; then
> ret=1
> @@ -57,16 +65,44 @@ is_elf() {
> elf_needs_rpath() {
> local file="${1}"
> local hostdir="${2}"
> +
> + [ -n "$(get_libs "${file}" "${hostdir}")" ]
> +}
> +
> +# This function returns all non-toolchain libs tha tare not in HOST_DIR
> +get_missing_libs() {
> + local file="${1}"
> + local hostdir="${2}"
> + local lib
> +
> + get_libs "${file}" "${hostdir}" \
> + | while read lib; do
> + if [ -not -e "${hostdir}/lib/${lib}" ]; then
> + printf '%s\n' "${lib}"
> + fi
> + done
> +}
> +
> +# This function returns the list of non-toolchain libraries that an ELF
> +# file has as DT_NEEDED
> +get_libs() {
> + local file="${1}"
> + local hostdir="${2}"
> local lib
>
> while read lib; do
> - [ -e "${hostdir}/lib/${lib}" ] && return 0
> + case "${lib}" in
> + libc.so*|libm.so*|libstdc++.so*|libpthread.so*|libgcc_s.so*|libdl.so*|ld-*|libgomp.so*|libcrypt.so*|libcrypto.so*|libatomic.so*|librt.so*|libutil.so*|libresolv.so*)
> + continue
> + ;;
> + *)
> + printf '%s\n' "${lib}"
> + ;;
> + esac
> done < <( readelf -d "${file}" 2>/dev/null \
> |sed -r -e '/^.* \(NEEDED\) .*Shared library: \[(.+)\]$/!d;' \
> -e 's//\1/;' \
> )
> -
> - return 1
> }
OK, I'll review this and try to get back with a v3... hopefully
earlier than in 4 years!
Thanks for the prompt review and feedback!
Thomas
--
Thomas Petazzoni, co-owner and CEO, Bootlin
Embedded Linux and Kernel engineering and training
https://bootlin.com
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
prev parent reply other threads:[~2026-08-25 8:19 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-24 21:34 [Buildroot] [PATCH v2] support/scripts/check-host-libs: add new check on host binaries/libs Thomas Petazzoni via buildroot
2026-08-25 7:22 ` Alexis Lothoré via buildroot
2026-08-25 7:31 ` Yann E. MORIN via buildroot
2026-08-25 8:19 ` Thomas Petazzoni via buildroot [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ao1Pks3_H87lajHF@windsurf \
--to=buildroot@buildroot.org \
--cc=David.Laight@aculab.com \
--cc=arnout@mind.be \
--cc=thomas.petazzoni@bootlin.com \
--cc=yann.morin.1998@free.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox