From 9f39d431f7f34e674a872f170c395e28776b81a8 Mon Sep 17 00:00:00 2001 From: ZSY-ARCH Date: Thu, 30 Jul 2026 14:41:26 +0800 Subject: [PATCH 1/2] Add arm64/armhf Ubuntu libc support and fix deb unpacking - get_all_debian() accepts an arch regex param (default amd64|i386) - New 'ubuntu-arm' category in ./get, fetching arm64/armhf glibc/musl/ eglibc/dietlibc from ports.ubuntu.com - download: fix false 'Failed to save' errors when a lib subdir (e.g. gconv/) is present; add usr/lib/, lib64, usr/lib64 layout support --- README.md | 1 + common/libc.sh | 6 +++++- download | 12 ++++++++++-- get | 13 +++++++++++++ 4 files changed, 29 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 5b465c1..26b710a 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,7 @@ database: $ ./get # List categories $ ./get ubuntu debian # Download Ubuntu's and Debian's libc, old default behavior + $ ./get ubuntu-arm # Download Ubuntu's arm64/armhf libc from ports.ubuntu.com $ ./get all # Download all categories. Can take a while! You can also add a custom libc to your database. diff --git a/common/libc.sh b/common/libc.sh index 067f85e..1ac3e12 100644 --- a/common/libc.sh +++ b/common/libc.sh @@ -136,7 +136,11 @@ get_all_debian() { local info=$1 local url=$2 local pkgname=$3 - for f in `wget $url/ -O - 2>/dev/null | grep -Eoh "$pkgname"'(-i386|-amd64|-x32)?_[^"]*(amd64|i386)\.deb' |grep -v ""`; do + # arch is a grep -E alternation of Debian architecture names to match in the + # .deb filename, e.g. "amd64|i386" or "arm64|armhf". Defaults to the + # traditional x86 architectures for backwards compatibility. + local arch="${4:-amd64|i386}" + for f in `wget $url/ -O - 2>/dev/null | grep -Eoh "$pkgname"'(-i386|-amd64|-x32|-armel|-armhf|-arm64)?_[^"]*('"$arch"')\.deb' |grep -v ""`; do get_debian "$url/$f" "$info" "$pkgname" done return 0 diff --git a/download b/download index 69e9918..f6950ba 100755 --- a/download +++ b/download @@ -35,8 +35,16 @@ download_single() { popd 1>/dev/null mkdir libs/$id - cp $tmp/lib/*/* libs/$id 2>/dev/null || cp $tmp/lib32/* libs/$id 2>/dev/null \ - || die "Failed to save. Check it manually $tmp" + # Depending on the distro/architecture and whether merged-/usr is in use, + # the shared libraries can live under lib/, usr/lib/ + # (e.g. modern amd64/arm64 packages), lib32 (i386 multiarch on amd64), or + # lib64/usr/lib64 (amd64 multiarch on i386, e.g. libc6-amd64). + # Only copy regular files (not subdirs like gconv/, audit/), and rely on + # find succeeding rather than cp's exit code, since cp exits non-zero + # whenever a directory is among its arguments even if all files copied. + find $tmp/lib/*/ $tmp/usr/lib/*/ $tmp/lib32/ $tmp/lib64/ $tmp/usr/lib64/ \ + -maxdepth 1 -type f -exec cp -t libs/$id {} + 2>/dev/null + [ "$(ls -A libs/$id 2>/dev/null)" ] || die "Failed to save. Check it manually $tmp" echo " -> Package saved to libs/$id" rm -rf $tmp diff --git a/get b/get index 3cb0aa1..bb5b72c 100755 --- a/get +++ b/get @@ -24,6 +24,19 @@ ubuntu() { get_all_debian ubuntu-old-dietlibc http://old-releases.ubuntu.com/ubuntu/pool/universe/d/dietlibc/ dietlibc } +categories[cntr_category]="ubuntu-arm" +requirements["ubuntu-arm"]="requirements_debian" +cntr_category=$((cntr_category + 1)) +ubuntu_arm_archs="arm64|armhf" +ubuntu-arm() { + # Ubuntu ports archive hosts arm64/armhf (and other non-x86) builds, + # including security updates, all under the same pool directory. + get_all_debian ubuntu-arm-eglibc http://ports.ubuntu.com/ubuntu-ports/pool/main/e/eglibc/ libc6 "$ubuntu_arm_archs" + get_all_debian ubuntu-arm-glibc http://ports.ubuntu.com/ubuntu-ports/pool/main/g/glibc/ libc6 "$ubuntu_arm_archs" + get_all_debian ubuntu-arm-musl http://ports.ubuntu.com/ubuntu-ports/pool/universe/m/musl/ musl "$ubuntu_arm_archs" + get_all_debian ubuntu-arm-dietlibc http://ports.ubuntu.com/ubuntu-ports/pool/universe/d/dietlibc/ dietlibc "$ubuntu_arm_archs" +} + categories[cntr_category]="debian" requirements["debian"]="requirements_debian" cntr_category=$((cntr_category + 1)) From 13a572d340df92524c4d398c3c0ec81e9d8c7b5e Mon Sep 17 00:00:00 2001 From: ZSY-ARCH Date: Thu, 30 Jul 2026 16:35:23 +0800 Subject: [PATCH 2/2] Fix __libc_start_main_ret detection on ARM and locale-dependent symbol loss - dump_libc_start_main_ret now recognizes ARM/AArch64 call instructions (bl/blr/blx) in addition to x86's call, fixing ./dump failures on arm64/armhf libc entries. - dump_symbols now forces LC_ALL=C sort -u, since locale-aware collation (e.g. en_US.UTF-8) could silently drop symbols differing only by a leading underscore (e.g. dup2 vs __dup2). --- common/libc.sh | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/common/libc.sh b/common/libc.sh index 1ac3e12..43b3c46 100644 --- a/common/libc.sh +++ b/common/libc.sh @@ -8,7 +8,10 @@ die() { } dump_symbols() { - readelf -Ws $1 | perl -n -e '/: (\w+)\s+\w+\s+(?:FUNC|OBJECT)\s+(?:\w+\s+){3}(\w+)\b(?:@@GLIBC)?/ && print "$2 $1\n"' | sort -u + # Force byte-order (C locale) sorting: under locale-aware collation (e.g. + # en_US.UTF-8), `sort -u` can treat symbols differing only by leading + # underscores as equal (e.g. "__dup2" and "dup2"), silently dropping one. + readelf -Ws $1 | perl -n -e '/: (\w+)\s+\w+\s+(?:FUNC|OBJECT)\s+(?:\w+\s+){3}(\w+)\b(?:@@GLIBC)?/ && print "$2 $1\n"' | LC_ALL=C sort -u } extract_label() { @@ -16,9 +19,13 @@ extract_label() { } dump_libc_start_main_ret() { + # Match the "call" instruction on the relevant architecture: x86 uses + # "call"; ARM/AArch64 use "bl" (direct branch-with-link), "blr" (AArch64 + # register-indirect branch-with-link) or "blx" (ARM/Thumb register-indirect + # branch-with-link, used to call the app-specific main()). local call_main=`objdump -D $1 \ | grep -EA 100 '<__libc_start_main.*>:' \ - | grep call \ + | grep -E '\b(call|bl|blr|blx)\b' \ | grep -EB 1 '' \ | head -n 1 \ | extract_label` @@ -27,7 +34,7 @@ dump_libc_start_main_ret() { if [[ "$call_main" == "" ]]; then local call_main=`objdump -D $1 \ | grep -EB 100 '<__libc_start_main.*>:' \ - | grep call \ + | grep -E '\b(call|bl|blr|blx)\b' \ | grep -EB 1 '' \ | head -n 1 \ | extract_label`