consmirror.c: the BSD notice is replaced (Makronix's own file). Files with changes of other sessions pending are left for their commit. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
36 lines
1.4 KiB
Bash
36 lines
1.4 KiB
Bash
#!/bin/sh
|
|
# License: CNCL 1.0 (Could Not Care Less), see LICENSE at the top of the tree.
|
|
#
|
|
# Check a program built for the phone (mobile/userland/mk/mx.prog.mk):
|
|
# it is an aarch64 ELF, every shared library it needs is in the sysroot, and
|
|
# no symbol version it needs is newer than what the sysroot's library offers
|
|
# (the sysroot is the phone's image, tools/mksysroot.sh) -- the thing that
|
|
# breaks a binary at run time and not at link time.
|
|
#
|
|
# Usage: mxcheck.sh SYSROOT PROGRAM
|
|
|
|
set -eu
|
|
[ $# -eq 2 ] || { echo "usage: $0 SYSROOT PROGRAM" >&2; exit 2; }
|
|
sysroot=$1 prog=$2
|
|
fail() { echo "mxcheck: $prog: $*" >&2; exit 1; }
|
|
|
|
# the tooldir's binutils (tools/mxmake.sh sets MX_READELF)
|
|
readelf=${MX_READELF:-aarch64-linux-gnu-readelf}
|
|
"$readelf" -h "$prog" 2>/dev/null | grep -q 'Machine:.*AArch64' || fail "not an aarch64 ELF"
|
|
|
|
for lib in $("$readelf" -d "$prog" | sed -n 's/.*(NEEDED).*\[\(.*\)\]/\1/p'); do
|
|
f=
|
|
for d in usr/lib lib; do
|
|
[ -e "$sysroot/$d/$lib" ] && { f=$sysroot/$d/$lib; break; }
|
|
done
|
|
[ -n "$f" ] || fail "needs $lib, which the phone's image does not have"
|
|
# every version the program asks of this library must be defined there
|
|
for v in $("$readelf" -V "$prog" | awk -v l="$lib" '
|
|
/File:/ { cur = $0; sub(/.*File: /, "", cur); sub(/ .*/, "", cur) }
|
|
/Name:/ && cur == l { print $3 }'); do
|
|
"$readelf" -V "$(readlink -f "$f")" | grep -q "Name: $v\$" ||
|
|
fail "needs $v of $lib, the phone's $lib does not define it"
|
|
done
|
|
done
|
|
echo "mxcheck: $prog ok"
|