* [Buildroot] [PATCH 1/4] support/scripts/check-host-bins: check shared libraries
@ 2026-09-09 12:39 Matthew Weber
2026-09-09 12:39 ` [Buildroot] [PATCH 2/4] support/scripts/check-host-bins: report RPATH errors after library errors Matthew Weber
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Matthew Weber @ 2026-09-09 12:39 UTC (permalink / raw)
To: buildroot; +Cc: thomas.petazzoni, yann.morin.1998, Matthew Weber
Shared libraries installed in HOST_DIR/lib do not have a program interpreter,
so they were skipped by the existing ELF check. Detect ET_DYN ELF files as
well as executables and scan HOST_DIR/lib.
Accept $ORIGIN as a valid RPATH for shared libraries in HOST_DIR/lib, where
it resolves to the directory containing the library.
Assisted-by: GitHub Copilot [VS Code]
Signed-off-by: Matthew Weber <matt@thewebers.ws>
---
Depends on v3 of the check-host-bins series:
https://patchwork.ozlabs.org/project/buildroot/list/?series=520240
The test script is available at:
https://gist.github.com/matthew-l-weber/34fae15a4319a81462961eadf0e31164
Review of v3 found that its new host-library check scanned only
HOST_DIR/bin and HOST_DIR/sbin. Its ELF test also required a program
interpreter, which excludes ET_DYN shared libraries in HOST_DIR/lib.
Test 3g builds a shared library in a synthetic HOST_DIR/lib with a
DT_NEEDED entry for a second library that is deliberately not installed in
HOST_DIR/lib. It verifies that check-host-bins scans the shared object and
reports the missing dependency.
Test 3j builds a shared library whose dependency is installed in the same
synthetic HOST_DIR/lib and whose RPATH is $ORIGIN. It verifies that this
valid RPATH does not produce an RPATH diagnostic.
support/scripts/check-host-bins | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
---
diff --git a/support/scripts/check-host-bins b/support/scripts/check-host-bins
index 098e35e592..cddf6a08b2 100755
--- a/support/scripts/check-host-bins
+++ b/support/scripts/check-host-bins
@@ -1,6 +1,6 @@
#!/usr/bin/env bash
-# This script scans $(HOST_DIR)/{bin,sbin} for all ELF files, and checks
+# This script scans $(HOST_DIR)/{bin,sbin,lib} for all ELF files, and checks
# they have an RPATH to $(HOST_DIR)/lib if they need libraries from
# there.
@@ -36,16 +36,20 @@ main() {
printf "*** ERROR: package %s installs executables without proper RPATH:\n" "${pkg}"
fi
printf "*** %s\n" "${file}"
- done < <( find "${hostdir}"/{bin,sbin} -type f 2>/dev/null )
+ done < <( find "${hostdir}"/{bin,sbin,lib} -type f 2>/dev/null )
return ${ret}
}
is_elf() {
local f="${1}"
+ local magic
- readelf -l "${f}" 2>/dev/null \
- |grep -E 'Requesting program interpreter:' >/dev/null 2>&1
+ { read -r -N 4 magic < "${f}"; } 2>/dev/null \
+ && [ "${magic}" = $'\x7fELF' ] || return 1
+
+ readelf -h "${f}" 2>/dev/null \
+ | grep -qE 'Type:[[:space:]]+(EXEC|DYN)'
}
# This function tells whether a given ELF executable (first argument)
@@ -129,6 +133,7 @@ check_elf_has_rpath() {
dir="$( sed -r -e 's:/+:/:g; s:/$::;' <<<"${dir}" )"
[ "${dir}" = "${hostdir}/lib" ] && return 0
[ "${dir}" = "\$ORIGIN/../lib" ] && return 0
+ [ "${dir}" = "\$ORIGIN" ] && [[ "${file}" == "${hostdir}/lib/"* ]] && return 0
# This check is done even for builds where
# BR2_PER_PACKAGE_DIRECTORIES is disabled. In this case,
# PER_PACKAGE_DIR and therefore ${perpackagedir} points to
--
2.39.5
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply related [flat|nested] 6+ messages in thread* [Buildroot] [PATCH 2/4] support/scripts/check-host-bins: report RPATH errors after library errors
2026-09-09 12:39 [Buildroot] [PATCH 1/4] support/scripts/check-host-bins: check shared libraries Matthew Weber
@ 2026-09-09 12:39 ` Matthew Weber
2026-09-09 13:23 ` Thomas Petazzoni via buildroot
2026-09-09 12:39 ` [Buildroot] [PATCH 3/4] support/scripts/check-host-bins: skip RPATH check for missing libraries Matthew Weber
2026-09-09 12:39 ` [Buildroot] [PATCH 4/4] support/scripts/check-host-bins: allow musl libc names Matthew Weber
2 siblings, 1 reply; 6+ messages in thread
From: Matthew Weber @ 2026-09-09 12:39 UTC (permalink / raw)
To: buildroot; +Cc: thomas.petazzoni, yann.morin.1998, Matthew Weber
The missing-library check sets the overall error status before the RPATH
check. Use a separate flag for the RPATH diagnostic header so both errors are
reported when applicable.
Assisted-by: GitHub Copilot [VS Code]
Signed-off-by: Matthew Weber <matt@thewebers.ws>
---
Depends on v3 of the check-host-bins series:
https://patchwork.ozlabs.org/project/buildroot/list/?series=520240
The test script is available at:
https://gist.github.com/matthew-l-weber/34fae15a4319a81462961eadf0e31164
While exercising v3's missing-library check, a mixed dependency case exposed
that it sets the shared error status before the RPATH diagnostic is emitted.
The existing header guard then suppresses the RPATH header.
Test 3k creates a binary with two non-toolchain dependencies. One is placed
in the synthetic HOST_DIR/lib, while the other remains absent, and the binary
uses an invalid RPATH. It verifies that check-host-bins emits both the
missing-library diagnostic and a separate RPATH diagnostic header.
support/scripts/check-host-bins | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/support/scripts/check-host-bins b/support/scripts/check-host-bins
index cddf6a08b2..5233f6cd1d 100755
--- a/support/scripts/check-host-bins
+++ b/support/scripts/check-host-bins
@@ -12,12 +12,13 @@ main() {
local pkg="${1}"
local hostdir="${2}"
local perpackagedir="${3}"
- local file ret
+ local file ret rpath_hdr missing_libs
# Remove duplicate and trailing '/' for proper match
hostdir="$( sed -r -e 's:/+:/:g; s:/$::;' <<<"${hostdir}" )"
ret=0
+ rpath_hdr=0
while read -r file; do
is_elf "${file}" || continue
elf_needs_rpath "${file}" "${hostdir}" || continue
@@ -30,7 +31,8 @@ main() {
printf ' - %s\n' ${missing_libs}
fi
check_elf_has_rpath "${file}" "${hostdir}" "${perpackagedir}" && continue
- if [ ${ret} -eq 0 ]; then
+ if [ ${rpath_hdr} -eq 0 ]; then
+ rpath_hdr=1
ret=1
printf "***\n"
printf "*** ERROR: package %s installs executables without proper RPATH:\n" "${pkg}"
--
2.39.5
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply related [flat|nested] 6+ messages in thread* Re: [Buildroot] [PATCH 2/4] support/scripts/check-host-bins: report RPATH errors after library errors
2026-09-09 12:39 ` [Buildroot] [PATCH 2/4] support/scripts/check-host-bins: report RPATH errors after library errors Matthew Weber
@ 2026-09-09 13:23 ` Thomas Petazzoni via buildroot
0 siblings, 0 replies; 6+ messages in thread
From: Thomas Petazzoni via buildroot @ 2026-09-09 13:23 UTC (permalink / raw)
To: Matthew Weber; +Cc: buildroot, yann.morin.1998
On Wed, Sep 09, 2026 at 07:39:23AM -0500, Matthew Weber wrote:
> The missing-library check sets the overall error status before the RPATH
> check. Use a separate flag for the RPATH diagnostic header so both errors are
> reported when applicable.
The commit log is honestly hard to grasp.
> diff --git a/support/scripts/check-host-bins b/support/scripts/check-host-bins
> index cddf6a08b2..5233f6cd1d 100755
> --- a/support/scripts/check-host-bins
> +++ b/support/scripts/check-host-bins
> @@ -12,12 +12,13 @@ main() {
> local pkg="${1}"
> local hostdir="${2}"
> local perpackagedir="${3}"
> - local file ret
> + local file ret rpath_hdr missing_libs
missing_libs is added as a variable, but not used anywhere in this
patch. Unrelated change?
Overall this change should really be a review comment to my patch
"support/scripts/check-host-bins: add new check on host binaries/libs"
as it's a bug/issue introduced by this not yet merged patch.
But isn't your patch going to offer a messed up output like this:
****
**** ERROR: package %s uses libs not in HOST_DIR:
**** ERROR: package %s installs executables without proper RPATH:
**** file1
**** file2
isn't that a bit odd?
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
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Buildroot] [PATCH 3/4] support/scripts/check-host-bins: skip RPATH check for missing libraries
2026-09-09 12:39 [Buildroot] [PATCH 1/4] support/scripts/check-host-bins: check shared libraries Matthew Weber
2026-09-09 12:39 ` [Buildroot] [PATCH 2/4] support/scripts/check-host-bins: report RPATH errors after library errors Matthew Weber
@ 2026-09-09 12:39 ` Matthew Weber
2026-09-09 13:33 ` Thomas Petazzoni via buildroot
2026-09-09 12:39 ` [Buildroot] [PATCH 4/4] support/scripts/check-host-bins: allow musl libc names Matthew Weber
2 siblings, 1 reply; 6+ messages in thread
From: Matthew Weber @ 2026-09-09 12:39 UTC (permalink / raw)
To: buildroot; +Cc: thomas.petazzoni, yann.morin.1998, Matthew Weber
An ELF with only non-toolchain dependencies absent from HOST_DIR cannot use an
RPATH to find them. Report those missing dependencies, but skip the misleading
RPATH diagnostic.
Assisted-by: GitHub Copilot [VS Code]
Signed-off-by: Matthew Weber <matt@thewebers.ws>
---
Depends on v3 of the check-host-bins series:
https://patchwork.ozlabs.org/project/buildroot/list/?series=520240
The test script is available at:
https://gist.github.com/matthew-l-weber/34fae15a4319a81462961eadf0e31164
While exercising v3's missing-library check, an ELF with only external
non-toolchain dependencies was reported as both missing a library and missing
an RPATH. Since no relevant library exists in HOST_DIR, the latter diagnostic
is misleading.
Test 3h places /bin/ls in a synthetic HOST_DIR without its non-toolchain
dependencies. It verifies that check-host-bins reports the missing library
but does not also report an RPATH error when there is no HOST_DIR library to
locate.
Test 3l builds a binary with its non-toolchain dependency installed in the
synthetic HOST_DIR/lib but an invalid RPATH. It verifies that this valid
RPATH-check case still reports the RPATH diagnostic and not a missing-library
error.
support/scripts/check-host-bins | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/support/scripts/check-host-bins b/support/scripts/check-host-bins
index 5233f6cd1d..7e9b51cd4c 100755
--- a/support/scripts/check-host-bins
+++ b/support/scripts/check-host-bins
@@ -30,6 +30,7 @@ main() {
# shellcheck disable=SC2086 # we need the word splitting
printf ' - %s\n' ${missing_libs}
fi
+ any_lib_in_hostdir "${file}" "${hostdir}" || continue
check_elf_has_rpath "${file}" "${hostdir}" "${perpackagedir}" && continue
if [ ${rpath_hdr} -eq 0 ]; then
rpath_hdr=1
@@ -111,6 +112,18 @@ get_libs() {
)
}
+any_lib_in_hostdir() {
+ local file="${1}"
+ local hostdir="${2}"
+ local lib
+
+ while IFS= read -r lib; do
+ [ -e "${hostdir}/lib/${lib}" ] && return 0
+ done < <( get_libs "${file}" )
+
+ return 1
+}
+
# This function checks whether at least one of the RPATH of the given
# ELF executable (first argument) properly points to the host library
# directory (second argument), either through an absolute RPATH or a
--
2.39.5
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply related [flat|nested] 6+ messages in thread* Re: [Buildroot] [PATCH 3/4] support/scripts/check-host-bins: skip RPATH check for missing libraries
2026-09-09 12:39 ` [Buildroot] [PATCH 3/4] support/scripts/check-host-bins: skip RPATH check for missing libraries Matthew Weber
@ 2026-09-09 13:33 ` Thomas Petazzoni via buildroot
0 siblings, 0 replies; 6+ messages in thread
From: Thomas Petazzoni via buildroot @ 2026-09-09 13:33 UTC (permalink / raw)
To: Matthew Weber; +Cc: buildroot, yann.morin.1998
On Wed, Sep 09, 2026 at 07:39:24AM -0500, Matthew Weber wrote:
> An ELF with only non-toolchain dependencies absent from HOST_DIR cannot use an
> RPATH to find them. Report those missing dependencies, but skip the misleading
> RPATH diagnostic.
>
> Assisted-by: GitHub Copilot [VS Code]
> Signed-off-by: Matthew Weber <matt@thewebers.ws>
> ---
> Depends on v3 of the check-host-bins series:
> https://patchwork.ozlabs.org/project/buildroot/list/?series=520240
>
> The test script is available at:
> https://gist.github.com/matthew-l-weber/34fae15a4319a81462961eadf0e31164
>
> While exercising v3's missing-library check, an ELF with only external
> non-toolchain dependencies was reported as both missing a library and missing
> an RPATH. Since no relevant library exists in HOST_DIR, the latter diagnostic
> is misleading.
>
> Test 3h places /bin/ls in a synthetic HOST_DIR without its non-toolchain
> dependencies. It verifies that check-host-bins reports the missing library
> but does not also report an RPATH error when there is no HOST_DIR library to
> locate.
Hu? Why do we care?
If an ELF has non-toolchain library dependencies, then those must be
in HOST_DIR, and the binary must have an RPATH.
>
> Test 3l builds a binary with its non-toolchain dependency installed in the
> synthetic HOST_DIR/lib but an invalid RPATH. It verifies that this valid
> RPATH-check case still reports the RPATH diagnostic and not a missing-library
> error.
My understanding is that this is the nominal case and this commit
doesn't change anything about this.
Honestly, AI generated stuff is meh. Takes a massive amount of brain
energy because the commit log is meh, all to figure out that the
change is useless (if I'm not wrong, of course).
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
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Buildroot] [PATCH 4/4] support/scripts/check-host-bins: allow musl libc names
2026-09-09 12:39 [Buildroot] [PATCH 1/4] support/scripts/check-host-bins: check shared libraries Matthew Weber
2026-09-09 12:39 ` [Buildroot] [PATCH 2/4] support/scripts/check-host-bins: report RPATH errors after library errors Matthew Weber
2026-09-09 12:39 ` [Buildroot] [PATCH 3/4] support/scripts/check-host-bins: skip RPATH check for missing libraries Matthew Weber
@ 2026-09-09 12:39 ` Matthew Weber
2 siblings, 0 replies; 6+ messages in thread
From: Matthew Weber @ 2026-09-09 12:39 UTC (permalink / raw)
To: buildroot; +Cc: thomas.petazzoni, yann.morin.1998, Matthew Weber
musl-based host systems can name their C library libc.musl*. Treat these as
toolchain runtime libraries, like libc.so*.
Assisted-by: GitHub Copilot [VS Code]
Signed-off-by: Matthew Weber <matt@thewebers.ws>
---
Depends on v3 of the check-host-bins series:
https://patchwork.ozlabs.org/project/buildroot/list/?series=520240
The test script is available at:
https://gist.github.com/matthew-l-weber/34fae15a4319a81462961eadf0e31164
Test 3m builds a synthetic shared library named libc.musl-x86_64.so.1, then
links an executable against it. It confirms the executable has the expected
DT_NEEDED entry and verifies that check-host-bins accepts it without an
error.
Test 5, the cross-distro container test sequence, was also run. Its
Alpine 3.24 run exposed the missing libc.musl* allowlist entry; after this
change, the Alpine test sequence completed without reporting the musl C
library as missing.
support/scripts/check-host-bins | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/support/scripts/check-host-bins b/support/scripts/check-host-bins
index 7e9b51cd4c..42063d9c91 100755
--- a/support/scripts/check-host-bins
+++ b/support/scripts/check-host-bins
@@ -99,7 +99,7 @@ get_libs() {
while read -r lib; do
case "${lib}" in
- libc.so*|libm.so*|libstdc++.so*|libpthread.so*|libgcc_s.so*|libdl.so*|ld-*|libgomp.so*|libcrypt.so*|libatomic.so*|librt.so*|libutil.so*|libresolv.so*)
+ libc.so*|libm.so*|libstdc++.so*|libpthread.so*|libgcc_s.so*|libdl.so*|ld-*|libgomp.so*|libcrypt.so*|libatomic.so*|librt.so*|libutil.so*|libresolv.so*|libc.musl*)
continue
;;
*)
--
2.39.5
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply related [flat|nested] 6+ messages in thread
end of thread, other threads:[~2026-09-09 13:33 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-09 12:39 [Buildroot] [PATCH 1/4] support/scripts/check-host-bins: check shared libraries Matthew Weber
2026-09-09 12:39 ` [Buildroot] [PATCH 2/4] support/scripts/check-host-bins: report RPATH errors after library errors Matthew Weber
2026-09-09 13:23 ` Thomas Petazzoni via buildroot
2026-09-09 12:39 ` [Buildroot] [PATCH 3/4] support/scripts/check-host-bins: skip RPATH check for missing libraries Matthew Weber
2026-09-09 13:33 ` Thomas Petazzoni via buildroot
2026-09-09 12:39 ` [Buildroot] [PATCH 4/4] support/scripts/check-host-bins: allow musl libc names Matthew Weber
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.