From 9efb0743a97663738b77f4d09d244aad85691b9e Mon Sep 17 00:00:00 2001 From: AshishKumar Mishra Date: Tue, 5 May 2026 20:36:32 +0530 Subject: android-tools: move android-tools v29.x from dynamic-layers/selinux to meta-oe Relocate the recipe from dynamic-layers/selinux/ to the main meta-oe/recipes-devtools/ directory. The android-tools recipe (version 29.0.6.r14) was previously restricted to the selinux dynamic-layer. Investigation shows that version 29.0.6.r14 does not have a hard dependency on libselinux for core tool functionality. (adb, fastboot, and sparse image tools). - Basic runable test was done for binaries in android-tools-native - Checked for selinux absense by looking for selinx using $ ldd binary-name Changes: - Relocate recipe from dynamic-layers/selinux/ to recipes-devtools/ Signed-off-by: AshishKumar Mishra Signed-off-by: Khem Raj --- .../android-tools-conf/android-gadget-setup | 37 -- .../android-tools/android-tools-conf_1.0.bb | 20 - .../android-tools/0001-Fixes-for-yocto-build.patch | 164 ------ .../0001-liblp-fix-building-with-GCC-14.patch | 26 - ...ls-modifications-to-make-it-build-in-yoct.patch | 453 -------------- ...e-of-usbdevfs_urb-to-match-new-kernel-UAP.patch | 128 ---- .../0004-adb-Fix-build-on-big-endian-systems.patch | 50 -- .../0005-adb-Allow-adbd-to-be-run-as-root.patch | 25 - .../android-tools/android-tools/adbd.mk | 87 --- .../android-tools/android-tools-adbd.service | 13 - .../android-tools/debian/Add-riscv64-support.patch | 653 --------------------- .../debian/Added-missing-headers.patch | 46 -- .../android-tools/debian/Nonnull.patch | 22 - .../android-tools/debian/Vector-cast.patch | 16 - .../android-tools/debian/add-missing-headers.patch | 43 -- .../20150704-CVE-2015-3239_dwarf_i.h.patch | 15 - .../libunwind/legacy_built-in_sync_functions.patch | 28 - ...bunwind-fix-strchr-conformance-to-ISO-C23.patch | 27 - ...uard-unreachable-macro-to-avoid-redefinit.patch | 42 -- .../debian/external/libunwind/user_pt_regs.patch | 26 - .../debian/fix-attribute-issue-with-gcc.patch | 19 - .../debian/fix-build-on-non-x86.patch | 26 - .../debian/fix-gettid-exception-declaration.patch | 26 - .../debian/fix-standard-namespace-errors.patch | 24 - .../debian/hard-code-build-number.patch | 46 -- .../android-tools/debian/libusb-header-path.patch | 18 - .../debian/move-log-file-to-proper-dir.patch | 20 - .../android-tools/debian/simg_dump-python3.patch | 64 -- .../android-tools/debian/stdatomic.patch | 66 --- .../android-tools/debian/stub-out-fastdeploy.patch | 95 --- .../debian/system/core/Add-riscv64-support.patch | 653 --------------------- .../debian/system/core/Added-missing-headers.patch | 46 -- .../android-tools/debian/system/core/Nonnull.patch | 22 - .../debian/system/core/Vector-cast.patch | 16 - .../debian/system/core/add-missing-headers.patch | 43 -- ...ls-scope-write-macro-to-prevent-conflict-.patch | 52 -- .../system/core/fix-attribute-issue-with-gcc.patch | 19 - .../debian/system/core/fix-build-on-non-x86.patch | 26 - .../core/fix-gettid-exception-declaration.patch | 26 - .../core/fix-standard-namespace-errors.patch | 24 - .../system/core/hard-code-build-number.patch | 46 -- .../debian/system/core/libusb-header-path.patch | 18 - ...ve-fix-missing-fixed-width-integer-types-.patch | 38 -- .../system/core/move-log-file-to-proper-dir.patch | 20 - .../debian/system/core/simg_dump-python3.patch | 64 -- .../debian/system/core/stdatomic.patch | 66 --- .../debian/system/core/stub-out-fastdeploy.patch | 95 --- .../core/throw-exception-on-unknown-os.patch | 18 - .../debian/throw-exception-on-unknown-os.patch | 18 - .../android-tools/android-tools/remount | 2 - .../android-tools/android-tools/rules_yocto.mk | 1 - .../android-tools/android-tools_29.0.6.r14.bb | 193 ------ .../android-tools-conf/android-gadget-setup | 37 ++ .../android-tools/android-tools-conf_1.0.bb | 20 + .../android-tools/0001-Fixes-for-yocto-build.patch | 164 ++++++ .../0001-liblp-fix-building-with-GCC-14.patch | 26 + ...ls-modifications-to-make-it-build-in-yoct.patch | 453 ++++++++++++++ ...e-of-usbdevfs_urb-to-match-new-kernel-UAP.patch | 128 ++++ .../0004-adb-Fix-build-on-big-endian-systems.patch | 50 ++ .../0005-adb-Allow-adbd-to-be-run-as-root.patch | 25 + .../android-tools/android-tools/adbd.mk | 87 +++ .../android-tools/android-tools-adbd.service | 13 + .../android-tools/debian/Add-riscv64-support.patch | 653 +++++++++++++++++++++ .../debian/Added-missing-headers.patch | 46 ++ .../android-tools/debian/Nonnull.patch | 22 + .../android-tools/debian/Vector-cast.patch | 16 + .../android-tools/debian/add-missing-headers.patch | 43 ++ .../20150704-CVE-2015-3239_dwarf_i.h.patch | 15 + .../libunwind/legacy_built-in_sync_functions.patch | 28 + ...bunwind-fix-strchr-conformance-to-ISO-C23.patch | 27 + ...uard-unreachable-macro-to-avoid-redefinit.patch | 42 ++ .../debian/external/libunwind/user_pt_regs.patch | 26 + .../debian/fix-attribute-issue-with-gcc.patch | 19 + .../debian/fix-build-on-non-x86.patch | 26 + .../debian/fix-gettid-exception-declaration.patch | 26 + .../debian/fix-standard-namespace-errors.patch | 24 + .../debian/hard-code-build-number.patch | 46 ++ .../android-tools/debian/libusb-header-path.patch | 18 + .../debian/move-log-file-to-proper-dir.patch | 20 + .../android-tools/debian/simg_dump-python3.patch | 64 ++ .../android-tools/debian/stdatomic.patch | 66 +++ .../android-tools/debian/stub-out-fastdeploy.patch | 95 +++ .../debian/system/core/Add-riscv64-support.patch | 653 +++++++++++++++++++++ .../debian/system/core/Added-missing-headers.patch | 46 ++ .../android-tools/debian/system/core/Nonnull.patch | 22 + .../debian/system/core/Vector-cast.patch | 16 + .../debian/system/core/add-missing-headers.patch | 43 ++ ...ls-scope-write-macro-to-prevent-conflict-.patch | 52 ++ .../system/core/fix-attribute-issue-with-gcc.patch | 19 + .../debian/system/core/fix-build-on-non-x86.patch | 26 + .../core/fix-gettid-exception-declaration.patch | 26 + .../core/fix-standard-namespace-errors.patch | 24 + .../system/core/hard-code-build-number.patch | 46 ++ .../debian/system/core/libusb-header-path.patch | 18 + ...ve-fix-missing-fixed-width-integer-types-.patch | 38 ++ .../system/core/move-log-file-to-proper-dir.patch | 20 + .../debian/system/core/simg_dump-python3.patch | 64 ++ .../debian/system/core/stdatomic.patch | 66 +++ .../debian/system/core/stub-out-fastdeploy.patch | 95 +++ .../core/throw-exception-on-unknown-os.patch | 18 + .../debian/throw-exception-on-unknown-os.patch | 18 + .../android-tools/android-tools/remount | 2 + .../android-tools/android-tools/rules_yocto.mk | 1 + .../android-tools/android-tools_29.0.6.r14.bb | 193 ++++++ 104 files changed, 3831 insertions(+), 3831 deletions(-) delete mode 100644 meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools-conf/android-gadget-setup delete mode 100644 meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools-conf_1.0.bb delete mode 100644 meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/0001-Fixes-for-yocto-build.patch delete mode 100644 meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/0001-liblp-fix-building-with-GCC-14.patch delete mode 100644 meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/0002-android-tools-modifications-to-make-it-build-in-yoct.patch delete mode 100644 meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/0003-Update-usage-of-usbdevfs_urb-to-match-new-kernel-UAP.patch delete mode 100644 meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/0004-adb-Fix-build-on-big-endian-systems.patch delete mode 100644 meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/0005-adb-Allow-adbd-to-be-run-as-root.patch delete mode 100644 meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/adbd.mk delete mode 100644 meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/android-tools-adbd.service delete mode 100644 meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/debian/Add-riscv64-support.patch delete mode 100644 meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/debian/Added-missing-headers.patch delete mode 100644 meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/debian/Nonnull.patch delete mode 100644 meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/debian/Vector-cast.patch delete mode 100644 meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/debian/add-missing-headers.patch delete mode 100644 meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/debian/external/libunwind/20150704-CVE-2015-3239_dwarf_i.h.patch delete mode 100644 meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/debian/external/libunwind/legacy_built-in_sync_functions.patch delete mode 100644 meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/debian/external/libunwind/libunwind-fix-strchr-conformance-to-ISO-C23.patch delete mode 100644 meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/debian/external/libunwind/libunwind-guard-unreachable-macro-to-avoid-redefinit.patch delete mode 100644 meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/debian/external/libunwind/user_pt_regs.patch delete mode 100644 meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/debian/fix-attribute-issue-with-gcc.patch delete mode 100644 meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/debian/fix-build-on-non-x86.patch delete mode 100644 meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/debian/fix-gettid-exception-declaration.patch delete mode 100644 meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/debian/fix-standard-namespace-errors.patch delete mode 100644 meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/debian/hard-code-build-number.patch delete mode 100644 meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/debian/libusb-header-path.patch delete mode 100644 meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/debian/move-log-file-to-proper-dir.patch delete mode 100644 meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/debian/simg_dump-python3.patch delete mode 100644 meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/debian/stdatomic.patch delete mode 100644 meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/debian/stub-out-fastdeploy.patch delete mode 100644 meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/debian/system/core/Add-riscv64-support.patch delete mode 100644 meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/debian/system/core/Added-missing-headers.patch delete mode 100644 meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/debian/system/core/Nonnull.patch delete mode 100644 meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/debian/system/core/Vector-cast.patch delete mode 100644 meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/debian/system/core/add-missing-headers.patch delete mode 100644 meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/debian/system/core/android-tools-scope-write-macro-to-prevent-conflict-.patch delete mode 100644 meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/debian/system/core/fix-attribute-issue-with-gcc.patch delete mode 100644 meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/debian/system/core/fix-build-on-non-x86.patch delete mode 100644 meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/debian/system/core/fix-gettid-exception-declaration.patch delete mode 100644 meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/debian/system/core/fix-standard-namespace-errors.patch delete mode 100644 meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/debian/system/core/hard-code-build-number.patch delete mode 100644 meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/debian/system/core/libusb-header-path.patch delete mode 100644 meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/debian/system/core/libziparchive-fix-missing-fixed-width-integer-types-.patch delete mode 100644 meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/debian/system/core/move-log-file-to-proper-dir.patch delete mode 100644 meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/debian/system/core/simg_dump-python3.patch delete mode 100644 meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/debian/system/core/stdatomic.patch delete mode 100644 meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/debian/system/core/stub-out-fastdeploy.patch delete mode 100644 meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/debian/system/core/throw-exception-on-unknown-os.patch delete mode 100644 meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/debian/throw-exception-on-unknown-os.patch delete mode 100644 meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/remount delete mode 100644 meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/rules_yocto.mk delete mode 100644 meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools_29.0.6.r14.bb create mode 100644 meta-oe/recipes-devtools/android-tools/android-tools-conf/android-gadget-setup create mode 100644 meta-oe/recipes-devtools/android-tools/android-tools-conf_1.0.bb create mode 100644 meta-oe/recipes-devtools/android-tools/android-tools/0001-Fixes-for-yocto-build.patch create mode 100644 meta-oe/recipes-devtools/android-tools/android-tools/0001-liblp-fix-building-with-GCC-14.patch create mode 100644 meta-oe/recipes-devtools/android-tools/android-tools/0002-android-tools-modifications-to-make-it-build-in-yoct.patch create mode 100644 meta-oe/recipes-devtools/android-tools/android-tools/0003-Update-usage-of-usbdevfs_urb-to-match-new-kernel-UAP.patch create mode 100644 meta-oe/recipes-devtools/android-tools/android-tools/0004-adb-Fix-build-on-big-endian-systems.patch create mode 100644 meta-oe/recipes-devtools/android-tools/android-tools/0005-adb-Allow-adbd-to-be-run-as-root.patch create mode 100644 meta-oe/recipes-devtools/android-tools/android-tools/adbd.mk create mode 100644 meta-oe/recipes-devtools/android-tools/android-tools/android-tools-adbd.service create mode 100644 meta-oe/recipes-devtools/android-tools/android-tools/debian/Add-riscv64-support.patch create mode 100644 meta-oe/recipes-devtools/android-tools/android-tools/debian/Added-missing-headers.patch create mode 100644 meta-oe/recipes-devtools/android-tools/android-tools/debian/Nonnull.patch create mode 100644 meta-oe/recipes-devtools/android-tools/android-tools/debian/Vector-cast.patch create mode 100644 meta-oe/recipes-devtools/android-tools/android-tools/debian/add-missing-headers.patch create mode 100644 meta-oe/recipes-devtools/android-tools/android-tools/debian/external/libunwind/20150704-CVE-2015-3239_dwarf_i.h.patch create mode 100644 meta-oe/recipes-devtools/android-tools/android-tools/debian/external/libunwind/legacy_built-in_sync_functions.patch create mode 100644 meta-oe/recipes-devtools/android-tools/android-tools/debian/external/libunwind/libunwind-fix-strchr-conformance-to-ISO-C23.patch create mode 100644 meta-oe/recipes-devtools/android-tools/android-tools/debian/external/libunwind/libunwind-guard-unreachable-macro-to-avoid-redefinit.patch create mode 100644 meta-oe/recipes-devtools/android-tools/android-tools/debian/external/libunwind/user_pt_regs.patch create mode 100644 meta-oe/recipes-devtools/android-tools/android-tools/debian/fix-attribute-issue-with-gcc.patch create mode 100644 meta-oe/recipes-devtools/android-tools/android-tools/debian/fix-build-on-non-x86.patch create mode 100644 meta-oe/recipes-devtools/android-tools/android-tools/debian/fix-gettid-exception-declaration.patch create mode 100644 meta-oe/recipes-devtools/android-tools/android-tools/debian/fix-standard-namespace-errors.patch create mode 100644 meta-oe/recipes-devtools/android-tools/android-tools/debian/hard-code-build-number.patch create mode 100644 meta-oe/recipes-devtools/android-tools/android-tools/debian/libusb-header-path.patch create mode 100644 meta-oe/recipes-devtools/android-tools/android-tools/debian/move-log-file-to-proper-dir.patch create mode 100644 meta-oe/recipes-devtools/android-tools/android-tools/debian/simg_dump-python3.patch create mode 100644 meta-oe/recipes-devtools/android-tools/android-tools/debian/stdatomic.patch create mode 100644 meta-oe/recipes-devtools/android-tools/android-tools/debian/stub-out-fastdeploy.patch create mode 100644 meta-oe/recipes-devtools/android-tools/android-tools/debian/system/core/Add-riscv64-support.patch create mode 100644 meta-oe/recipes-devtools/android-tools/android-tools/debian/system/core/Added-missing-headers.patch create mode 100644 meta-oe/recipes-devtools/android-tools/android-tools/debian/system/core/Nonnull.patch create mode 100644 meta-oe/recipes-devtools/android-tools/android-tools/debian/system/core/Vector-cast.patch create mode 100644 meta-oe/recipes-devtools/android-tools/android-tools/debian/system/core/add-missing-headers.patch create mode 100644 meta-oe/recipes-devtools/android-tools/android-tools/debian/system/core/android-tools-scope-write-macro-to-prevent-conflict-.patch create mode 100644 meta-oe/recipes-devtools/android-tools/android-tools/debian/system/core/fix-attribute-issue-with-gcc.patch create mode 100644 meta-oe/recipes-devtools/android-tools/android-tools/debian/system/core/fix-build-on-non-x86.patch create mode 100644 meta-oe/recipes-devtools/android-tools/android-tools/debian/system/core/fix-gettid-exception-declaration.patch create mode 100644 meta-oe/recipes-devtools/android-tools/android-tools/debian/system/core/fix-standard-namespace-errors.patch create mode 100644 meta-oe/recipes-devtools/android-tools/android-tools/debian/system/core/hard-code-build-number.patch create mode 100644 meta-oe/recipes-devtools/android-tools/android-tools/debian/system/core/libusb-header-path.patch create mode 100644 meta-oe/recipes-devtools/android-tools/android-tools/debian/system/core/libziparchive-fix-missing-fixed-width-integer-types-.patch create mode 100644 meta-oe/recipes-devtools/android-tools/android-tools/debian/system/core/move-log-file-to-proper-dir.patch create mode 100644 meta-oe/recipes-devtools/android-tools/android-tools/debian/system/core/simg_dump-python3.patch create mode 100644 meta-oe/recipes-devtools/android-tools/android-tools/debian/system/core/stdatomic.patch create mode 100644 meta-oe/recipes-devtools/android-tools/android-tools/debian/system/core/stub-out-fastdeploy.patch create mode 100644 meta-oe/recipes-devtools/android-tools/android-tools/debian/system/core/throw-exception-on-unknown-os.patch create mode 100644 meta-oe/recipes-devtools/android-tools/android-tools/debian/throw-exception-on-unknown-os.patch create mode 100644 meta-oe/recipes-devtools/android-tools/android-tools/remount create mode 100644 meta-oe/recipes-devtools/android-tools/android-tools/rules_yocto.mk create mode 100644 meta-oe/recipes-devtools/android-tools/android-tools_29.0.6.r14.bb diff --git a/meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools-conf/android-gadget-setup b/meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools-conf/android-gadget-setup deleted file mode 100644 index 26cf30eddd..0000000000 --- a/meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools-conf/android-gadget-setup +++ /dev/null @@ -1,37 +0,0 @@ -#!/bin/sh - -[ ! -e /dev/pts ] && mkdir -p /dev/pts -[ ! -e /dev/pts/0 ] && mount devpts /dev/pts -t devpts - -# TODO enable the lines below once we have support for getprop -# retrieve the product info from Android -# manufacturer=$(getprop ro.product.manufacturer Android) -# model=$(getprop ro.product.model Android) -# serial=$(getprop ro.serialno 0123456789ABCDEF) - -#below are now needed in order to use FunctionFS for ADB, tested to work with 3.4+ kernels -if grep -q functionfs /proc/filesystems; then - mkdir -p /dev/usb-ffs/adb - mount -t functionfs adb /dev/usb-ffs/adb - #android-gadget-setup doesn't provide below 2 and without them it won't work, so we provide them here. - echo adb > /sys/class/android_usb/android0/f_ffs/aliases - echo ffs > /sys/class/android_usb/android0/functions -fi - -manufacturer="$(cat /system/build.prop | grep -o 'ro.product.manufacturer=.*' | cut -d'=' -f 2)" -model="$(cat /system/build.prop | grep -o 'ro.product.model=.*' | cut -d'=' -f 2)" -# get the device serial number from /proc/cmdline directly(since we have no getprop on -# GNU/Linux) -serial="$(cat /proc/cmdline | sed 's/.*androidboot.serialno=//' | sed 's/ .*//')" - -echo $serial > /sys/class/android_usb/android0/iSerial -echo $manufacturer > /sys/class/android_usb/android0/iManufacturer -echo $model > /sys/class/android_usb/android0/iProduct - -echo "0" > /sys/class/android_usb/android0/enable -echo "18d1" > /sys/class/android_usb/android0/idVendor -echo "D002" > /sys/class/android_usb/android0/idProduct -echo "adb" > /sys/class/android_usb/android0/functions -echo "1" > /sys/class/android_usb/android0/enable - -sleep 4 diff --git a/meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools-conf_1.0.bb b/meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools-conf_1.0.bb deleted file mode 100644 index 7bbac1db75..0000000000 --- a/meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools-conf_1.0.bb +++ /dev/null @@ -1,20 +0,0 @@ -DESCRIPTION = "Different utilities from Android - corresponding configuration files" -SECTION = "console/utils" -LICENSE = "MIT" -LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302" - -SRC_URI = "file://android-gadget-setup" - -S = "${UNPACKDIR}" - -do_install() { - install -d ${D}${bindir} - install -m 0755 ${UNPACKDIR}/android-gadget-setup ${D}${bindir} -} - -python () { - pn = d.getVar('PN') - profprov = d.getVar("PREFERRED_PROVIDER_" + pn) - if profprov and pn != profprov: - raise bb.parse.SkipRecipe("PREFERRED_PROVIDER_%s set to %s, not %s" % (pn, profprov, pn)) -} diff --git a/meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/0001-Fixes-for-yocto-build.patch b/meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/0001-Fixes-for-yocto-build.patch deleted file mode 100644 index 1d18d47ec3..0000000000 --- a/meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/0001-Fixes-for-yocto-build.patch +++ /dev/null @@ -1,164 +0,0 @@ -From 5de85f8273c7284aa93e35c40f025d4d43d42df9 Mon Sep 17 00:00:00 2001 -From: Etienne Cordonnier -Date: Thu, 16 Mar 2023 18:59:35 +0100 -Subject: [PATCH] Fixes for yocto build - -Signed-off-by: JJ Robertson -[rebased on version 29] -Signed-off-by: Etienne Cordonnier - ---- -Upstream-Status: Pending - - system/core/adb/daemon/file_sync_service.cpp | 4 ++-- - system/core/adb/daemon/framebuffer_service.h | 2 -- - system/core/adb/daemon/main.cpp | 5 +++-- - system/core/adb/daemon/restart_service.h | 2 -- - system/core/adb/daemon/services.cpp | 6 ++---- - system/core/adb/daemon/shell_service.cpp | 5 ++++- - system/core/adb/types.h | 1 + - 7 files changed, 12 insertions(+), 13 deletions(-) - -diff --git a/system/core/adb/daemon/file_sync_service.cpp b/system/core/adb/daemon/file_sync_service.cpp -index d6af7087..92e7087a 100644 ---- a/system/core/adb/daemon/file_sync_service.cpp -+++ b/system/core/adb/daemon/file_sync_service.cpp -@@ -111,7 +111,7 @@ static bool secure_mkdirs(const std::string& path) { - partial_path += path_component; - - if (should_use_fs_config(partial_path)) { -- fs_config(partial_path.c_str(), 1, nullptr, &uid, &gid, &mode, &capabilities); -+ // fs_config(partial_path.c_str(), 1, nullptr, &uid, &gid, &mode, &capabilities); - } - if (adb_mkdir(partial_path.c_str(), mode) == -1) { - if (errno != EEXIST) { -@@ -469,7 +469,7 @@ static bool do_send(int s, const std::string& spec, std::vector& buffer) { - uint64_t capabilities = 0; - if (should_use_fs_config(path)) { - unsigned int broken_api_hack = mode; -- fs_config(path.c_str(), 0, nullptr, &uid, &gid, &broken_api_hack, &capabilities); -+ // fs_config(path.c_str(), 0, nullptr, &uid, &gid, &broken_api_hack, &capabilities); - mode = broken_api_hack; - } - -diff --git a/system/core/adb/daemon/framebuffer_service.h b/system/core/adb/daemon/framebuffer_service.h -index bab44be3..264da597 100644 ---- a/system/core/adb/daemon/framebuffer_service.h -+++ b/system/core/adb/daemon/framebuffer_service.h -@@ -18,6 +18,4 @@ - - #include "adb_unique_fd.h" - --#if defined(__ANDROID__) - void framebuffer_service(unique_fd fd); --#endif -diff --git a/system/core/adb/daemon/main.cpp b/system/core/adb/daemon/main.cpp -index 3322574c..e807d13d 100644 ---- a/system/core/adb/daemon/main.cpp -+++ b/system/core/adb/daemon/main.cpp -@@ -208,6 +208,9 @@ int adbd_main(int server_port) { - umask(0); - - signal(SIGPIPE, SIG_IGN); -+ signal(SIGINT, SIG_DFL); -+ signal(SIGQUIT, SIG_DFL); -+ - - #if defined(__BIONIC__) - auto fdsan_level = android_fdsan_get_error_level(); -@@ -254,13 +257,11 @@ int adbd_main(int server_port) { - - bool is_usb = false; - --#if defined(__ANDROID__) - if (access(USB_FFS_ADB_EP0, F_OK) == 0) { - // Listen on USB. - usb_init(); - is_usb = true; - } --#endif - - // If one of these properties is set, also listen on that port. - // If one of the properties isn't set and we couldn't listen on usb, listen -diff --git a/system/core/adb/daemon/restart_service.h b/system/core/adb/daemon/restart_service.h -index 19840bd5..7a97614b 100644 ---- a/system/core/adb/daemon/restart_service.h -+++ b/system/core/adb/daemon/restart_service.h -@@ -18,9 +18,7 @@ - - #include "adb_unique_fd.h" - --#if defined(__ANDROID__) - void restart_root_service(unique_fd fd); - void restart_unroot_service(unique_fd fd); - void restart_tcp_service(unique_fd fd, int port); - void restart_usb_service(unique_fd fd); --#endif -diff --git a/system/core/adb/daemon/services.cpp b/system/core/adb/daemon/services.cpp -index 4ec90d27..d8541c23 100644 ---- a/system/core/adb/daemon/services.cpp -+++ b/system/core/adb/daemon/services.cpp -@@ -156,7 +156,7 @@ static void spin_service(unique_fd fd) { - } - #endif - // Fall through -- std::string cmd = "/system/bin/reboot "; -+ std::string cmd = "/sbin/reboot "; - cmd += name; - return StartSubprocess(cmd, nullptr, SubprocessType::kRaw, SubprocessProtocol::kNone); - } -@@ -265,11 +265,10 @@ unique_fd daemon_service_to_fd(std::string_view name, atransport* transport) { - } - #endif - --#if defined(__ANDROID__) - if (name.starts_with("framebuffer:")) { - return create_service_thread("fb", framebuffer_service); - } else if (android::base::ConsumePrefix(&name, "remount:")) { -- std::string cmd = "/system/bin/remount "; -+ std::string cmd = "/sbin/remount "; - cmd += name; - return StartSubprocess(cmd, nullptr, SubprocessType::kRaw, SubprocessProtocol::kNone); - } else if (android::base::ConsumePrefix(&name, "reboot:")) { -@@ -303,7 +302,6 @@ unique_fd daemon_service_to_fd(std::string_view name, atransport* transport) { - } else if (name.starts_with("usb:")) { - return create_service_thread("usb", restart_usb_service); - } --#endif - - if (android::base::ConsumePrefix(&name, "dev:")) { - return unique_fd{unix_open(name, O_RDWR | O_CLOEXEC)}; -diff --git a/system/core/adb/daemon/shell_service.cpp b/system/core/adb/daemon/shell_service.cpp -index f62032d0..ebcfe18d 100644 ---- a/system/core/adb/daemon/shell_service.cpp -+++ b/system/core/adb/daemon/shell_service.cpp -@@ -273,13 +273,16 @@ bool Subprocess::ForkAndExec(std::string* error) { - env["HOSTNAME"] = GetHostName(); - env["LOGNAME"] = pw->pw_name; - env["SHELL"] = pw->pw_shell; -- env["TMPDIR"] = "/data/local/tmp"; - env["USER"] = pw->pw_name; - } - - if (!terminal_type_.empty()) { - env["TERM"] = terminal_type_; - } -+ if (env.find("PS1") == env.end()) { -+ env["PS1"] = "\\h:\\w\\$ "; -+ } -+ - - std::vector joined_env; - for (const auto& it : env) { -diff --git a/system/core/adb/types.h b/system/core/adb/types.h -index c619fffc..f8e0f521 100644 ---- a/system/core/adb/types.h -+++ b/system/core/adb/types.h -@@ -22,6 +22,7 @@ - #include - #include - #include -+#include - - #include - diff --git a/meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/0001-liblp-fix-building-with-GCC-14.patch b/meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/0001-liblp-fix-building-with-GCC-14.patch deleted file mode 100644 index ccd289c81b..0000000000 --- a/meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/0001-liblp-fix-building-with-GCC-14.patch +++ /dev/null @@ -1,26 +0,0 @@ -From 9f4d839847666019cadf57aa34fd366801c11a44 Mon Sep 17 00:00:00 2001 -From: Dmitry Baryshkov -Date: Fri, 24 May 2024 14:13:35 +0300 -Subject: [PATCH] liblp: fix building with GCC 14 - -Upstream-Status: Pending -Signed-off-by: Dmitry Baryshkov ---- - system/core/fs_mgr/liblp/utility.cpp | 1 + - 1 file changed, 1 insertion(+) - -diff --git a/system/core/fs_mgr/liblp/utility.cpp b/system/core/fs_mgr/liblp/utility.cpp -index 48c5c8318d99..0aa8023aa87d 100644 ---- a/system/core/fs_mgr/liblp/utility.cpp -+++ b/system/core/fs_mgr/liblp/utility.cpp -@@ -24,6 +24,7 @@ - #include - #endif - -+#include - #include - #include - #include --- -2.39.2 - diff --git a/meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/0002-android-tools-modifications-to-make-it-build-in-yoct.patch b/meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/0002-android-tools-modifications-to-make-it-build-in-yoct.patch deleted file mode 100644 index a35428b5b4..0000000000 --- a/meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/0002-android-tools-modifications-to-make-it-build-in-yoct.patch +++ /dev/null @@ -1,453 +0,0 @@ -From 194513bababa9707ec54bc7119613a0d5eca9f79 Mon Sep 17 00:00:00 2001 -From: Etienne Cordonnier -Date: Fri, 17 Mar 2023 10:33:11 +0100 -Subject: [PATCH] android-tools: modifications to make it build in yocto - -- Fix relocation errors on aarch64, e.g.: -"relocation R_AARCH64_ADR_PREL_PG_HI21 against symbol `_ZTV19SparseFileBufSource' which may bind externally can not be used when making a shared object; recompile with -fPIC" - -- use ln -f to avoid error "File exists" on incremental builds - -- fix missing headers - -Signed-off-by: Etienne Cordonnier - -- fix warning: library search path "/usr/lib/p7zip" is unsafe for cross-compilation - -- fix error: include location "/usr/include/android" is unsafe for cross-compilation - -Upstream-Status: Pending -Signed-off-by: Hongxu Jia ---- - debian/development/etc1tool.mk | 1 - - debian/external/boringssl/libcrypto.mk | 1 + - debian/libnativehelper/libnativehelper.mk | 1 - - debian/system/core/adb.mk | 1 - - debian/system/core/append2simg.mk | 2 +- - debian/system/core/fastboot.mk | 3 +-- - debian/system/core/img2simg.mk | 2 +- - debian/system/core/libbacktrace.mk | 10 ++++------ - debian/system/core/libbase.mk | 5 +++-- - debian/system/core/libcutils.mk | 5 +++-- - debian/system/core/liblog.mk | 3 ++- - debian/system/core/libsparse.mk | 5 +++-- - debian/system/core/libutils.mk | 4 ++-- - debian/system/core/libziparchive.mk | 5 +++-- - debian/system/core/simg2img.mk | 2 +- - debian/system/core/simg2simg.mk | 2 +- - debian/system/extras/libext4_utils.mk | 1 - - frameworks/native/libs/adbd_auth/adbd_auth.cpp | 2 ++ - system/core/adb/adb_listeners.cpp | 12 ++++++------ - system/core/adb/transport_local.cpp | 2 +- - 20 files changed, 35 insertions(+), 34 deletions(-) - -diff --git a/debian/development/etc1tool.mk b/debian/development/etc1tool.mk -index 2d787e98bb86..e03ac5f0048c 100644 ---- a/debian/development/etc1tool.mk -+++ b/debian/development/etc1tool.mk -@@ -4,7 +4,6 @@ SOURCES = development/tools/etc1tool/etc1tool.cpp - - CXXFLAGS += -std=gnu++2a - CPPFLAGS += \ -- -I/usr/include/android \ - -Idevelopment/include \ - -Iframeworks/native/opengl/include \ - -diff --git a/debian/external/boringssl/libcrypto.mk b/debian/external/boringssl/libcrypto.mk -index c0ea54f4..b3a77bfd 100644 ---- a/debian/external/boringssl/libcrypto.mk -+++ b/debian/external/boringssl/libcrypto.mk -@@ -27,6 +27,7 @@ CPPFLAGS += \ - -DBORINGSSL_IMPLEMENTATION \ - -DBORINGSSL_SHARED_LIBRARY \ - -DOPENSSL_SMALL \ -+ -DOPENSSL_NO_ASM \ - -Iexternal/boringssl/src/crypto \ - -Iexternal/boringssl/src/include \ - -diff --git a/debian/libnativehelper/libnativehelper.mk b/debian/libnativehelper/libnativehelper.mk -index 7a0c94a6b7b5..880b2fdf9154 100644 ---- a/debian/libnativehelper/libnativehelper.mk -+++ b/debian/libnativehelper/libnativehelper.mk -@@ -11,7 +11,6 @@ OBJECTS = $(SOURCES:.cpp=.o) - - CXXFLAGS += -std=gnu++2a - CPPFLAGS += \ -- -I/usr/include/android \ - -Ilibnativehelper/header_only_include \ - -Ilibnativehelper/include \ - -Ilibnativehelper/include_jni \ -diff --git a/debian/system/core/adb.mk b/debian/system/core/adb.mk -index 9769b68ab793..58c9a63bd225 100644 ---- a/debian/system/core/adb.mk -+++ b/debian/system/core/adb.mk -@@ -19,7 +19,6 @@ CPPFLAGS += \ - -D_GNU_SOURCE \ - -DADB_HOST=1 \ - -DADB_VERSION='"$(DEB_VERSION)"' \ -- -I/usr/include/android \ - -Iexternal/boringssl/include \ - -Isystem/core/adb \ - -Isystem/core/base/include \ -@@ -28,7 +27,6 @@ CPPFLAGS += \ - LDFLAGS += \ - -Ldebian/out/system/core \ - -Wl,-rpath=/usr/lib/$(DEB_HOST_MULTIARCH)/android \ -- -fuse-ld=gold \ - -lbase \ - -lcutils \ - -lpthread \ -diff --git a/debian/system/core/append2simg.mk b/debian/system/core/append2simg.mk -index 1599bdb8..598c751d 100644 ---- a/debian/system/core/append2simg.mk -+++ b/debian/system/core/append2simg.mk -@@ -11,7 +11,7 @@ CPPFLAGS += \ - - LDFLAGS += \ - -Ldebian/out/system/core \ -- -Wl,-rpath=/usr/lib/$(DEB_HOST_MULTIARCH)/android \ -+ -Wl,-rpath='$$ORIGIN/../lib/android' \ - -lbase \ - -llog \ - -lpthread \ -diff --git a/debian/system/core/fastboot.mk b/debian/system/core/fastboot.mk -index d5c9a285..a59ba1a4 100644 ---- a/debian/system/core/fastboot.mk -+++ b/debian/system/core/fastboot.mk -@@ -30,7 +30,6 @@ CXXFLAGS += -std=gnu++2a -fpermissive - CPPFLAGS += \ - -D_FILE_OFFSET_BITS=64 \ - -DPLATFORM_TOOLS_VERSION='"$(PLATFORM_TOOLS_VERSION)"' \ -- -I/usr/include/android \ - -Iexternal/boringssl/include \ - -Iexternal/avb \ - -Isystem/core/adb \ -@@ -49,8 +48,7 @@ CPPFLAGS += \ - - LDFLAGS += \ - -Ldebian/out/system/core \ -- -Wl,-rpath=/usr/lib/$(DEB_HOST_MULTIARCH)/android \ -- -fuse-ld=gold \ -+ -Wl,-rpath='$$ORIGIN/../lib/android' \ - -lbase \ - -lcutils \ - -lpthread \ -diff --git a/debian/system/core/img2simg.mk b/debian/system/core/img2simg.mk -index 11adf014..8baf5ba5 100644 ---- a/debian/system/core/img2simg.mk -+++ b/debian/system/core/img2simg.mk -@@ -11,7 +11,7 @@ CPPFLAGS += \ - - LDFLAGS += \ - -Ldebian/out/system/core \ -- -Wl,-rpath=/usr/lib/$(DEB_HOST_MULTIARCH)/android \ -+ -Wl,-rpath='$$ORIGIN/../lib/android' \ - -lbase \ - -llog \ - -lpthread \ -diff --git a/debian/system/core/libbacktrace.mk b/debian/system/core/libbacktrace.mk -index e3411d76..e7dd984c 100644 ---- a/debian/system/core/libbacktrace.mk -+++ b/debian/system/core/libbacktrace.mk -@@ -1,4 +1,4 @@ --include /usr/share/dpkg/architecture.mk -+include rules_yocto.mk - - NAME = libbacktrace - -@@ -81,12 +81,10 @@ CPPFLAGS += \ - -Isystem/core/libunwindstack/include \ - - LDFLAGS += \ -- -L/usr/lib/p7zip \ - -Ldebian/out/system/core \ -- -Wl,-rpath=/usr/lib/p7zip \ -- -Wl,-rpath=/usr/lib/$(DEB_HOST_MULTIARCH)/android \ -+ -Wl,-rpath='$$ORIGIN' \ - -Wl,-soname,$(NAME).so.0 \ -- -l:7z.so \ -+ -l7z \ - -lbase \ - -llog \ - -lpthread \ -@@ -101,7 +99,7 @@ endif - build: $(OBJECTS_CXX) $(OBJECTS_ASSEMBLY) debian/out/external/libunwind/libunwind.a - mkdir -p debian/out/system/core - $(CXX) $^ -o debian/out/system/core/$(NAME).so.0 $(LDFLAGS) -- cd debian/out/system/core && ln -s $(NAME).so.0 $(NAME).so -+ cd debian/out/system/core && ln -sf $(NAME).so.0 $(NAME).so - - $(OBJECTS_CXX): %.o: %.cpp - $(CXX) -c -o $@ $< $(CXXFLAGS) $(CPPFLAGS) -diff --git a/debian/system/core/libbase.mk b/debian/system/core/libbase.mk -index d2b074ba..8a90d6de 100644 ---- a/debian/system/core/libbase.mk -+++ b/debian/system/core/libbase.mk -@@ -1,3 +1,4 @@ -+include rules_yocto.mk - NAME = libbase - - SOURCES = \ -@@ -30,7 +31,7 @@ CPPFLAGS += \ - - LDFLAGS += \ - -Ldebian/out/system/core \ -- -Wl,-rpath=/usr/lib/$(DEB_HOST_MULTIARCH)/android \ -+ -Wl,-rpath='$$ORIGIN' \ - -Wl,-soname,$(NAME).so.0 \ - -llog \ - -lpthread \ -@@ -44,7 +45,7 @@ endif - - build: $(OBJECTS) - $(CXX) $^ -o debian/out/system/core/$(NAME).so.0 $(LDFLAGS) -- cd debian/out/system/core && ln -s $(NAME).so.0 $(NAME).so -+ cd debian/out/system/core && ln -sf $(NAME).so.0 $(NAME).so - - $(OBJECTS): %.o: %.cpp - $(CXX) -c -o $@ $< $(CXXFLAGS) $(CPPFLAGS) -diff --git a/debian/system/core/libcutils.mk b/debian/system/core/libcutils.mk -index 9d928b56..c22b0965 100644 ---- a/debian/system/core/libcutils.mk -+++ b/debian/system/core/libcutils.mk -@@ -1,3 +1,4 @@ -+include rules_yocto.mk - NAME = libcutils - - libcutils_nonwindows_sources = \ -@@ -47,7 +48,7 @@ CPPFLAGS += \ - - LDFLAGS += \ - -Ldebian/out/system/core \ -- -Wl,-rpath=/usr/lib/$(DEB_HOST_MULTIARCH)/android \ -+ -Wl,-rpath='$$ORIGIN' \ - -Wl,-soname,$(NAME).so.0 \ - -lbase \ - -llog \ -@@ -56,7 +57,7 @@ LDFLAGS += \ - - build: $(OBJECTS_C) $(OBJECTS_CXX) - $(CXX) $^ -o debian/out/system/core/$(NAME).so.0 $(LDFLAGS) -- cd debian/out/system/core && ln -s $(NAME).so.0 $(NAME).so -+ cd debian/out/system/core && ln -sf $(NAME).so.0 $(NAME).so - - $(OBJECTS_C): %.o: %.c - $(CC) -c -o $@ $< $(CFLAGS) $(CPPFLAGS) -diff --git a/debian/system/core/liblog.mk b/debian/system/core/liblog.mk -index f8c3d7fe..34a07341 100644 ---- a/debian/system/core/liblog.mk -+++ b/debian/system/core/liblog.mk -@@ -1,3 +1,4 @@ -+include rules_yocto.mk - NAME = liblog - - liblog_sources = \ -@@ -35,7 +36,7 @@ LDFLAGS += \ - build: $(OBJECTS) - mkdir -p debian/out/system/core - $(CXX) $^ -o debian/out/system/core/$(NAME).so.0 $(LDFLAGS) -- cd debian/out/system/core && ln -s $(NAME).so.0 $(NAME).so -+ cd debian/out/system/core && ln -sf $(NAME).so.0 $(NAME).so - - $(OBJECTS): %.o: %.cpp - $(CXX) -c -o $@ $< $(CXXFLAGS) $(CPPFLAGS) -diff --git a/debian/system/core/libsparse.mk b/debian/system/core/libsparse.mk -index c2b2694c..2da12b8e 100644 ---- a/debian/system/core/libsparse.mk -+++ b/debian/system/core/libsparse.mk -@@ -1,3 +1,4 @@ -+include rules_yocto.mk - NAME = libsparse - - SOURCES = \ -@@ -19,7 +20,7 @@ CPPFLAGS += \ - - LDFLAGS += \ - -Ldebian/out/system/core \ -- -Wl,-rpath=/usr/lib/$(DEB_HOST_MULTIARCH)/android \ -+ -Wl,-rpath='$$ORIGIN' \ - -Wl,-soname,$(NAME).so.0 \ - -lbase \ - -lz \ -@@ -27,7 +28,7 @@ LDFLAGS += \ - - build: $(OBJECTS) - $(CXX) $^ -o debian/out/system/core/$(NAME).so.0 $(LDFLAGS) -- cd debian/out/system/core && ln -s $(NAME).so.0 $(NAME).so -+ cd debian/out/system/core && ln -sf $(NAME).so.0 $(NAME).so - - $(OBJECTS): %.o: %.cpp - $(CXX) -c -o $@ $< $(CXXFLAGS) $(CPPFLAGS) -diff --git a/debian/system/core/libutils.mk b/debian/system/core/libutils.mk -index c37b1d2d..0c748c8b 100644 ---- a/debian/system/core/libutils.mk -+++ b/debian/system/core/libutils.mk -@@ -1,4 +1,4 @@ --include /usr/share/dpkg/architecture.mk -+include rules_yocto.mk - - NAME = libutils - -@@ -41,7 +41,7 @@ CPPFLAGS += \ - - LDFLAGS += \ - -Ldebian/out/system/core \ -- -Wl,-rpath=/usr/lib/$(DEB_HOST_MULTIARCH)/android \ -+ -Wl,-rpath='$$ORIGIN' \ - -Wl,-soname,$(NAME).so.0 \ - -lbacktrace \ - -lcutils \ -diff --git a/debian/system/core/libziparchive.mk b/debian/system/core/libziparchive.mk -index 1b286b4e..1b7499be 100644 ---- a/debian/system/core/libziparchive.mk -+++ b/debian/system/core/libziparchive.mk -@@ -1,3 +1,4 @@ -+include rules_yocto.mk - NAME = libziparchive - - SOURCES = \ -@@ -19,7 +20,7 @@ CPPFLAGS += \ - - LDFLAGS += \ - -Ldebian/out/system/core \ -- -Wl,-rpath=/usr/lib/$(DEB_HOST_MULTIARCH)/android \ -+ -Wl,-rpath='$$ORIGIN' \ - -Wl,-soname,$(NAME).so.0 \ - -lbase \ - -llog \ -@@ -29,7 +30,7 @@ LDFLAGS += \ - - build: $(OBJECTS) - $(CXX) $^ -o debian/out/system/core/$(NAME).so.0 $(LDFLAGS) -- cd debian/out/system/core && ln -s $(NAME).so.0 $(NAME).so -+ cd debian/out/system/core && ln -sf $(NAME).so.0 $(NAME).so - - $(OBJECTS): %.o: %.cc - $(CXX) -c -o $@ $< $(CXXFLAGS) $(CPPFLAGS) -diff --git a/debian/system/core/simg2img.mk b/debian/system/core/simg2img.mk -index f6e3f59d..df4f44f3 100644 ---- a/debian/system/core/simg2img.mk -+++ b/debian/system/core/simg2img.mk -@@ -13,7 +13,7 @@ CPPFLAGS += \ - - LDFLAGS += \ - -Ldebian/out/system/core \ -- -Wl,-rpath=/usr/lib/$(DEB_HOST_MULTIARCH)/android \ -+ -Wl,-rpath='$$ORIGIN/../lib/android' \ - -lbase \ - -llog \ - -lpthread \ -diff --git a/debian/system/core/simg2simg.mk b/debian/system/core/simg2simg.mk -index ed53b04c..646ab030 100644 ---- a/debian/system/core/simg2simg.mk -+++ b/debian/system/core/simg2simg.mk -@@ -13,7 +13,7 @@ CPPFLAGS += \ - - LDFLAGS += \ - -Ldebian/out/system/core \ -- -Wl,-rpath=/usr/lib/$(DEB_HOST_MULTIARCH)/android \ -+ -Wl,-rpath='$$ORIGIN/../lib/android' \ - -lbase \ - -llog \ - -lpthread \ -diff --git a/debian/system/extras/libext4_utils.mk b/debian/system/extras/libext4_utils.mk -index 264bb95ad36a..99125097c8e3 100644 ---- a/debian/system/extras/libext4_utils.mk -+++ b/debian/system/extras/libext4_utils.mk -@@ -25,7 +25,6 @@ CPPFLAGS += \ - -D_LARGEFILE64_SOURCE \ - -DFEC_NO_KLOG \ - -DSQUASHFS_NO_KLOG \ -- -I/usr/include/android \ - -Isystem/core/base/include \ - -Isystem/core/libcutils/include \ - -Isystem/core/libsparse/include \ -diff --git a/frameworks/native/libs/adbd_auth/adbd_auth.cpp b/frameworks/native/libs/adbd_auth/adbd_auth.cpp -index a9c23110..6ca334ba 100644 ---- a/frameworks/native/libs/adbd_auth/adbd_auth.cpp -+++ b/frameworks/native/libs/adbd_auth/adbd_auth.cpp -@@ -23,8 +23,10 @@ - #include - #include - -+#include - #include - #include -+#include - #include - #include - #include -diff --git a/system/core/adb/adb_listeners.cpp b/system/core/adb/adb_listeners.cpp -index 29909a55..440cdbd4 100644 ---- a/system/core/adb/adb_listeners.cpp -+++ b/system/core/adb/adb_listeners.cpp -@@ -109,7 +109,7 @@ static void listener_event_func(int _fd, unsigned ev, void* _l) - } - - // Called as a transport disconnect function. |arg| is the raw alistener*. --static void listener_disconnect(void* arg, atransport*) EXCLUDES(listener_list_mutex) { -+static void listener_disconnect(void* arg, atransport*) { - std::lock_guard lock(listener_list_mutex); - for (auto iter = listener_list.begin(); iter != listener_list.end(); ++iter) { - if (iter->get() == arg) { -@@ -121,7 +121,7 @@ static void listener_disconnect(void* arg, atransport*) EXCLUDES(listener_list_m - } - - // Write the list of current listeners (network redirections) into a string. --std::string format_listeners() EXCLUDES(listener_list_mutex) { -+std::string format_listeners() { - std::lock_guard lock(listener_list_mutex); - std::string result; - for (auto& l : listener_list) { -@@ -140,7 +140,7 @@ std::string format_listeners() EXCLUDES(listener_list_mutex) { - } - - InstallStatus remove_listener(const char* local_name, atransport* transport) -- EXCLUDES(listener_list_mutex) { -+{ - std::lock_guard lock(listener_list_mutex); - for (auto iter = listener_list.begin(); iter != listener_list.end(); ++iter) { - if (local_name == (*iter)->local_name) { -@@ -151,7 +151,7 @@ InstallStatus remove_listener(const char* local_name, atransport* transport) - return INSTALL_STATUS_LISTENER_NOT_FOUND; - } - --void remove_all_listeners() EXCLUDES(listener_list_mutex) { -+void remove_all_listeners() { - std::lock_guard lock(listener_list_mutex); - auto iter = listener_list.begin(); - while (iter != listener_list.end()) { -@@ -164,7 +164,7 @@ void remove_all_listeners() EXCLUDES(listener_list_mutex) { - } - } - --void close_smartsockets() EXCLUDES(listener_list_mutex) { -+void close_smartsockets() { - std::lock_guard lock(listener_list_mutex); - auto pred = [](const std::unique_ptr& listener) { - return listener->local_name == "*smartsocket*"; -@@ -174,7 +174,7 @@ void close_smartsockets() EXCLUDES(listener_list_mutex) { - - InstallStatus install_listener(const std::string& local_name, const char* connect_to, - atransport* transport, int no_rebind, int* resolved_tcp_port, -- std::string* error) EXCLUDES(listener_list_mutex) { -+ std::string* error) { - std::lock_guard lock(listener_list_mutex); - for (auto& l : listener_list) { - if (local_name == l->local_name) { -diff --git a/system/core/adb/transport_local.cpp b/system/core/adb/transport_local.cpp -index c7261860..5988ec4d 100644 ---- a/system/core/adb/transport_local.cpp -+++ b/system/core/adb/transport_local.cpp -@@ -333,7 +333,7 @@ struct EmulatorConnection : public FdConnection { - - /* Only call this function if you already hold local_transports_lock. */ - static atransport* find_emulator_transport_by_adb_port_locked(int adb_port) -- REQUIRES(local_transports_lock) { -+{ - auto it = local_transports.find(adb_port); - if (it == local_transports.end()) { - return nullptr; --- -2.34.1 - diff --git a/meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/0003-Update-usage-of-usbdevfs_urb-to-match-new-kernel-UAP.patch b/meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/0003-Update-usage-of-usbdevfs_urb-to-match-new-kernel-UAP.patch deleted file mode 100644 index ea934f44d8..0000000000 --- a/meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/0003-Update-usage-of-usbdevfs_urb-to-match-new-kernel-UAP.patch +++ /dev/null @@ -1,128 +0,0 @@ -From 02b6b6977d80af4b9b806054fadb5a06cedf011d Mon Sep 17 00:00:00 2001 -From: Etienne Cordonnier -Date: Tue, 14 Mar 2023 11:33:50 +0100 -Subject: [PATCH] Update usage of usbdevfs_urb to match new kernel UAPI -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -Linux kernel API has been changed by commit 94dfc73e7cf4 ("treewide: uapi: Replace zero-length arrays with flexible-array members") -where zero-length array iso_frame_desc in struct usbdevfs_urb was replaced with a proper flexible-array member. - -Current USB API usage causes a compilation error at Linux 6.0: - -In file included from /home/mae/.cache/kiss/proc/121205/build/android-tools/vendor/adb/client/usb_linux.cpp:28: -/usr/include/linux/usbdevice_fs.h:134:41: error: flexible array member ‘usbdevfs_urb::iso_frame_desc’ not at end of ‘struct usb_handle’ - 134 | struct usbdevfs_iso_packet_desc iso_frame_desc[]; - | ^~~~~~~~~~~~~~ -/home/mae/.cache/kiss/proc/121205/build/android-tools/vendor/adb/client/usb_linux.cpp:76:18: note: next member ‘usbdevfs_urb usb_handle::urb_out’ declared here - 76 | usbdevfs_urb urb_out; - | ^~~~~~~ -/home/mae/.cache/kiss/proc/121205/build/android-tools/vendor/adb/client/usb_linux.cpp:61:8: note: in the definition of ‘struct usb_handle’ - 61 | struct usb_handle { - | ^~~~~~~~~~ - -Fix it by using pointers to a struct with flexible-array members. -Current fix works both with the old and the new API. - -See https://github.com/nmeum/android-tools/issues/74 for more context. - -Tested: built on Linux against kernel 5.19 and 6.0; 'adb shell' over USB -cable -Acked-by: Gustavo A. R. Silva gustavoars@kernel.org -Change-Id: I7f0f7b35d9a3ab980d3520b541b60c7857a6b101 -Signed-off-by: Anatol Pomozov - -[Backported on version 10] -Signed-off-by: Etienne Cordonnier - ---- -Upstream-Status: Pending - - system/core/adb/client/usb_linux.cpp | 24 ++++++++++++++---------- - 1 file changed, 14 insertions(+), 10 deletions(-) - -diff --git a/system/core/adb/client/usb_linux.cpp b/system/core/adb/client/usb_linux.cpp -index 343e7b59..6a4479f3 100644 ---- a/system/core/adb/client/usb_linux.cpp -+++ b/system/core/adb/client/usb_linux.cpp -@@ -71,8 +71,8 @@ struct usb_handle : public ::usb_handle { - unsigned zero_mask; - unsigned writeable = 1; - -- usbdevfs_urb urb_in; -- usbdevfs_urb urb_out; -+ usbdevfs_urb *urb_in; -+ usbdevfs_urb *urb_out; - - bool urb_in_busy = false; - bool urb_out_busy = false; -@@ -305,7 +305,7 @@ static int usb_bulk_write(usb_handle* h, const void* data, int len) { - std::unique_lock lock(h->mutex); - D("++ usb_bulk_write ++"); - -- usbdevfs_urb* urb = &h->urb_out; -+ usbdevfs_urb* urb = h->urb_out; - memset(urb, 0, sizeof(*urb)); - urb->type = USBDEVFS_URB_TYPE_BULK; - urb->endpoint = h->ep_out; -@@ -344,7 +344,7 @@ static int usb_bulk_read(usb_handle* h, void* data, int len) { - std::unique_lock lock(h->mutex); - D("++ usb_bulk_read ++"); - -- usbdevfs_urb* urb = &h->urb_in; -+ usbdevfs_urb* urb = h->urb_in; - memset(urb, 0, sizeof(*urb)); - urb->type = USBDEVFS_URB_TYPE_BULK; - urb->endpoint = h->ep_in; -@@ -389,7 +389,7 @@ static int usb_bulk_read(usb_handle* h, void* data, int len) { - } - D("[ urb @%p status = %d, actual = %d ]", out, out->status, out->actual_length); - -- if (out == &h->urb_in) { -+ if (out == h->urb_in) { - D("[ reap urb - IN complete ]"); - h->urb_in_busy = false; - if (urb->status != 0) { -@@ -398,7 +398,7 @@ static int usb_bulk_read(usb_handle* h, void* data, int len) { - } - return urb->actual_length; - } -- if (out == &h->urb_out) { -+ if (out == h->urb_out) { - D("[ reap urb - OUT compelete ]"); - h->urb_out_busy = false; - h->cv.notify_all(); -@@ -502,10 +502,10 @@ void usb_kick(usb_handle* h) { - ** but this ensures that a reader blocked on REAPURB - ** will get unblocked - */ -- ioctl(h->fd, USBDEVFS_DISCARDURB, &h->urb_in); -- ioctl(h->fd, USBDEVFS_DISCARDURB, &h->urb_out); -- h->urb_in.status = -ENODEV; -- h->urb_out.status = -ENODEV; -+ ioctl(h->fd, USBDEVFS_DISCARDURB, h->urb_in); -+ ioctl(h->fd, USBDEVFS_DISCARDURB, h->urb_out); -+ h->urb_in->status = -ENODEV; -+ h->urb_out->status = -ENODEV; - h->urb_in_busy = false; - h->urb_out_busy = false; - h->cv.notify_all(); -@@ -521,6 +521,8 @@ int usb_close(usb_handle* h) { - - D("-- usb close %p (fd = %d) --", h, h->fd); - -+ delete h->urb_in; -+ delete h->urb_out; - delete h; - - return 0; -@@ -556,6 +558,8 @@ static void register_device(const char* dev_name, const char* dev_path, unsigned - usb->ep_out = ep_out; - usb->zero_mask = zero_mask; - usb->max_packet_size = max_packet_size; -+ usb->urb_in = new usbdevfs_urb; -+ usb->urb_out = new usbdevfs_urb; - - // Initialize mark so we don't get garbage collected after the device scan. - usb->mark = true; diff --git a/meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/0004-adb-Fix-build-on-big-endian-systems.patch b/meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/0004-adb-Fix-build-on-big-endian-systems.patch deleted file mode 100644 index c82423908f..0000000000 --- a/meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/0004-adb-Fix-build-on-big-endian-systems.patch +++ /dev/null @@ -1,50 +0,0 @@ -From e4a29888cb52c1eafd3ab57a6e220b38147ecfbe Mon Sep 17 00:00:00 2001 -From: Etienne Cordonnier -Date: Tue, 14 Mar 2023 13:39:23 +0100 -Subject: [PATCH] adb: Fix build on big endian systems - -The usb_linux_client.c file defines cpu_to_le16/32 by using the C -library htole16/32 function calls. However, cpu_to_le16/32 are used -when initializing structures, i.e in a context where a function call -is not allowed. - -It works fine on little endian systems because htole16/32 are defined -by the C library as no-ops. But on big-endian systems, they are -actually doing something, which might involve calling a function, -causing build failures. - -To solve this, we simply open-code cpu_to_le16/32 in a way that allows -them to be used when initializing structures. - -Signed-off-by: Thomas Petazzoni -[Forward-ported to version 29] -Signed-off-by: Etienne Cordonnier - ---- -Upstream-Status: Pending - - system/core/adb/daemon/usb_ffs.cpp | 11 +++++++++-- - 1 file changed, 9 insertions(+), 2 deletions(-) - -diff --git a/system/core/adb/daemon/usb_ffs.cpp b/system/core/adb/daemon/usb_ffs.cpp -index b19fa5d5..ef2291ca 100644 ---- a/system/core/adb/daemon/usb_ffs.cpp -+++ b/system/core/adb/daemon/usb_ffs.cpp -@@ -39,8 +39,15 @@ - - #define USB_EXT_PROP_UNICODE 1 - --#define cpu_to_le16(x) htole16(x) --#define cpu_to_le32(x) htole32(x) -+#if __BYTE_ORDER == __LITTLE_ENDIAN -+# define cpu_to_le16(x) (x) -+# define cpu_to_le32(x) (x) -+#else -+# define cpu_to_le16(x) ((((x) >> 8) & 0xffu) | (((x) & 0xffu) << 8)) -+# define cpu_to_le32(x) \ -+ ((((x) & 0xff000000u) >> 24) | (((x) & 0x00ff0000u) >> 8) | \ -+ (((x) & 0x0000ff00u) << 8) | (((x) & 0x000000ffu) << 24)) -+#endif - - // clang-format off - struct func_desc { diff --git a/meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/0005-adb-Allow-adbd-to-be-run-as-root.patch b/meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/0005-adb-Allow-adbd-to-be-run-as-root.patch deleted file mode 100644 index dfbdc2af66..0000000000 --- a/meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/0005-adb-Allow-adbd-to-be-run-as-root.patch +++ /dev/null @@ -1,25 +0,0 @@ -From 4ef35041ba5c02df48c31f2382e7c3c4316ad936 Mon Sep 17 00:00:00 2001 -From: Etienne Cordonnier -Date: Tue, 14 Mar 2023 13:53:51 +0100 -Subject: [PATCH] adb: Allow adbd to be run as root - -Signed-off-by: Etienne Cordonnier - ---- -Upstream-Status: Pending - - system/core/adb/daemon/main.cpp | 1 + - 1 file changed, 1 insertion(+) - -diff --git a/system/core/adb/daemon/main.cpp b/system/core/adb/daemon/main.cpp -index e807d13d..309663a2 100644 ---- a/system/core/adb/daemon/main.cpp -+++ b/system/core/adb/daemon/main.cpp -@@ -75,6 +75,7 @@ static bool should_drop_capabilities_bounding_set() { - } - - static bool should_drop_privileges() { -+ return true; - // "adb root" not allowed, always drop privileges. - if (!ALLOW_ADBD_ROOT && !is_device_unlocked()) return true; - diff --git a/meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/adbd.mk b/meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/adbd.mk deleted file mode 100644 index 3282216b8e..0000000000 --- a/meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/adbd.mk +++ /dev/null @@ -1,87 +0,0 @@ -include rules_yocto.mk -NAME = adbd - -SOURCES = \ - adb/adbconnection/adbconnection_server.cpp \ - adb/daemon/auth.cpp \ - adb/daemon/file_sync_service.cpp \ - adb/daemon/file_sync_service.h \ - adb/daemon/framebuffer_service.cpp \ - adb/daemon/framebuffer_service.h \ - adb/daemon/jdwp_service.cpp \ - adb/daemon/main.cpp \ - adb/daemon/restart_service.cpp \ - adb/daemon/restart_service.h \ - adb/daemon/services.cpp \ - adb/daemon/shell_service.cpp \ - adb/daemon/shell_service.h \ - adb/daemon/usb_ffs.cpp \ - adb/daemon/usb_legacy.cpp \ - adb/daemon/usb.cpp \ - adb/shell_service_protocol.cpp \ - adb/adb.cpp \ - adb/adb_io.cpp \ - adb/adb_listeners.cpp \ - adb/adb_trace.cpp \ - adb/adb_unique_fd.cpp \ - adb/adb_utils.cpp \ - adb/fdevent/fdevent.cpp \ - adb/fdevent/fdevent_epoll.cpp \ - adb/services.cpp \ - adb/sockets.cpp \ - adb/socket_spec.cpp \ - adb/sysdeps/errno.cpp \ - adb/sysdeps/posix/network.cpp \ - adb/sysdeps_unix.cpp \ - adb/transport.cpp \ - adb/transport_fd.cpp \ - adb/transport_local.cpp \ - adb/transport_usb.cpp \ - adb/types.cpp \ - diagnose_usb/diagnose_usb.cpp \ - libasyncio/AsyncIO.cpp \ - -SOURCES := $(foreach source, $(SOURCES), system/core/$(source)) - -SOURCES += \ - frameworks/native/libs/adbd_auth/adbd_auth.cpp - -CXXFLAGS += -std=gnu++20 -CPPFLAGS += -Isystem/coreinclude -Isystem/core/adb -Isystem/core/base/include -Idebian/out/system/core -Isystem/tools/mkbootimg/include/bootimg -Isystem/core/fs_mgr/include \ - -Isystem/core/fs_mgr/include_fstab \ - -DADB_VERSION='"$(DEB_VERSION)"' -D_GNU_SOURCE -LDFLAGS += -Wl,-rpath='$$ORIGIN/../lib/android' -Wl,-rpath-link='$$ORIGIN/../lib/android' \ - -lpthread -Ldebian/out/system/core -Ldebian/out/external/boringssl -lbase -lcrypto_utils -l:libcrypto.a -lcutils -llog -lresolv - -PAGE_SIZE ?= 4096 - -CXXFLAGS += -UADB_HOST -CXXFLAGS += -DADB_HOST=0 -CXXFLAGS += -DALLOW_ADBD_DISABLE_VERITY -CXXFLAGS += -DALLOW_ADBD_NO_AUTH -CXXFLAGS += -DPLATFORM_TOOLS_VERSION='"28.0.2"' -CXXFLAGS += -Isystem/core/diagnose_usb/include -CXXFLAGS += -Isystem/core/adb/daemon/include -CXXFLAGS += -Isystem/core/adb/adbconnection/include -CXXFLAGS += -Isystem/core/libasyncio/include -CXXFLAGS += -Isystem/core/libcutils/include -CXXFLAGS += -Isystem/core/libcrypto_utils/include -CXXFLAGS += -Isystem/core/liblog/include/ -CXXFLAGS += -Isystem/core/libutils/include -CXXFLAGS += -Iframeworks/native/libs/adbd_auth/include -CXXFLAGS += -Wno-c++11-narrowing -CXXFLAGS += -DPAGE_SIZE=$(PAGE_SIZE) - - -# -latomic should be the last library specified -# https://github.com/android/ndk/issues/589 -ifneq ($(filter armel mipsel,$(DEB_HOST_ARCH)),) - LDFLAGS += -latomic -endif - -build: $(SOURCES) - mkdir --parents debian/out/system/core - $(CXX) $^ -o debian/out/system/core/adbd $(CXXFLAGS) $(CPPFLAGS) $(LDFLAGS) - -clean: - $(RM) debian/out/system/core/adbd diff --git a/meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/android-tools-adbd.service b/meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/android-tools-adbd.service deleted file mode 100644 index b6661f2e39..0000000000 --- a/meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/android-tools-adbd.service +++ /dev/null @@ -1,13 +0,0 @@ -[Unit] -Description=Android Debug Bridge -ConditionPathExists=/etc/usb-debugging-enabled -Before=android-system.service - -[Service] -Type=simple -Restart=on-failure -ExecStartPre=-/usr/bin/android-gadget-setup adb -ExecStart=/usr/bin/adbd - -[Install] -WantedBy=basic.target diff --git a/meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/debian/Add-riscv64-support.patch b/meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/debian/Add-riscv64-support.patch deleted file mode 100644 index 9fd0fa792c..0000000000 --- a/meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/debian/Add-riscv64-support.patch +++ /dev/null @@ -1,653 +0,0 @@ -From: Guo Ren -Date: Wed, 29 Jun 2022 16:46:46 +0800 -Subject: Add riscv64 support - -This patch contains the dwarf unwind support for 64bit risc-v. - - * DwarfCfa.cpp (cfa_def_cfa_register): setup register if CFA_REG is - not setup for riscv64 - * Elf.cpp (GetRelPc): convert offset to virtual address for riscv64. - * ElfInterface.cpp (GetVirtAddrFromOffset): New for riscv64. - * RegsRiscv64.cpp (StepIfSignalHandler): Fix signal frame check. - libunwindstack/include/unwindstack/ - * ElfInterface.h (GetVirtAddrFromOffset): New for riscv64. - libunwindstack/tests/ - * DwarfCfaTest.cpp (cfa_def_cfa_register): ok for riscv64. - * RegsStepIfSignalHandlerTest.cpp (riscv64_step_if_signal_handler): Fix - testcase for riscv64 - -Test: Builds. -Test: All unit tests pass. - -Signed-off-by: Guo Ren -Signed-off-by: Lifang Xia -Signed-off-by: Mao Han -Change-Id: Ib21ddf23cc83f332af202df7bffcaceec16063e0 ---- -Upstream-Status: Pending - - system/core/libunwindstack/Android.bp | 1 + - system/core/libunwindstack/Elf.cpp | 2 + - system/core/libunwindstack/Regs.cpp | 10 ++ - system/core/libunwindstack/RegsRiscv64.cpp | 156 +++++++++++++++++++++ - .../core/libunwindstack/include/unwindstack/Elf.h | 5 + - .../include/unwindstack/MachineRiscv64.h | 59 ++++++++ - .../include/unwindstack/RegsGetLocal.h | 43 ++++++ - .../include/unwindstack/RegsRiscv64.h | 59 ++++++++ - .../include/unwindstack/UcontextRiscv64.h | 80 +++++++++++ - .../include/unwindstack/UserRiscv64.h | 37 +++++ - system/core/libunwindstack/tools/unwind.cpp | 3 + - .../core/libunwindstack/tools/unwind_symbols.cpp | 3 + - 12 files changed, 458 insertions(+) - create mode 100644 system/core/libunwindstack/RegsRiscv64.cpp - create mode 100644 system/core/libunwindstack/include/unwindstack/MachineRiscv64.h - create mode 100644 system/core/libunwindstack/include/unwindstack/RegsRiscv64.h - create mode 100644 system/core/libunwindstack/include/unwindstack/UcontextRiscv64.h - create mode 100644 system/core/libunwindstack/include/unwindstack/UserRiscv64.h - -diff --git a/system/core/libunwindstack/Android.bp b/system/core/libunwindstack/Android.bp -index 3695f72..f1f9c68 100644 ---- a/system/core/libunwindstack/Android.bp -+++ b/system/core/libunwindstack/Android.bp -@@ -70,6 +70,7 @@ cc_library { - "RegsArm64.cpp", - "RegsX86.cpp", - "RegsX86_64.cpp", -+ "RegsRiscv64.cpp", - "RegsMips.cpp", - "RegsMips64.cpp", - "Unwinder.cpp", -diff --git a/system/core/libunwindstack/Elf.cpp b/system/core/libunwindstack/Elf.cpp -index f01b092..3c2088b 100644 ---- a/system/core/libunwindstack/Elf.cpp -+++ b/system/core/libunwindstack/Elf.cpp -@@ -290,6 +290,8 @@ ElfInterface* Elf::CreateInterfaceFromMemory(Memory* memory) { - arch_ = ARCH_X86_64; - } else if (e_machine == EM_MIPS) { - arch_ = ARCH_MIPS64; -+ } else if (e_machine == EM_RISCV) { -+ arch_ = ARCH_RISCV64; - } else { - // Unsupported. - ALOGI("64 bit elf that is neither aarch64 nor x86_64 nor mips64: e_machine = %d\n", -diff --git a/system/core/libunwindstack/Regs.cpp b/system/core/libunwindstack/Regs.cpp -index c7dec52..447a554 100644 ---- a/system/core/libunwindstack/Regs.cpp -+++ b/system/core/libunwindstack/Regs.cpp -@@ -27,12 +27,14 @@ - #include - #include - #include -+#include - #include - #include - #include - #include - #include - #include -+#include - #include - #include - -@@ -67,6 +69,8 @@ Regs* Regs::RemoteGet(pid_t pid) { - return RegsMips::Read(buffer.data()); - case sizeof(mips64_user_regs): - return RegsMips64::Read(buffer.data()); -+ case sizeof(riscv64_user_regs): -+ return RegsRiscv64::Read(buffer.data()); - } - return nullptr; - } -@@ -85,6 +89,8 @@ Regs* Regs::CreateFromUcontext(ArchEnum arch, void* ucontext) { - return RegsMips::CreateFromUcontext(ucontext); - case ARCH_MIPS64: - return RegsMips64::CreateFromUcontext(ucontext); -+ case ARCH_RISCV64: -+ return RegsRiscv64::CreateFromUcontext(ucontext); - case ARCH_UNKNOWN: - default: - return nullptr; -@@ -104,6 +110,8 @@ ArchEnum Regs::CurrentArch() { - return ARCH_MIPS; - #elif defined(__mips__) && defined(__LP64__) - return ARCH_MIPS64; -+#elif defined(__riscv) -+ return ARCH_RISCV64; - #else - abort(); - #endif -@@ -123,6 +131,8 @@ Regs* Regs::CreateFromLocal() { - regs = new RegsMips(); - #elif defined(__mips__) && defined(__LP64__) - regs = new RegsMips64(); -+#elif defined(__riscv) -+ regs = new RegsRiscv64(); - #else - abort(); - #endif -diff --git a/system/core/libunwindstack/RegsRiscv64.cpp b/system/core/libunwindstack/RegsRiscv64.cpp -new file mode 100644 -index 0000000..887762a ---- /dev/null -+++ b/system/core/libunwindstack/RegsRiscv64.cpp -@@ -0,0 +1,156 @@ -+/* -+ * Copyright (C) 2022 The Android Open Source Project -+ * -+ * Licensed under the Apache License, Version 2.0 (the "License"); -+ * you may not use this file except in compliance with the License. -+ * You may obtain a copy of the License at -+ * -+ * http://www.apache.org/licenses/LICENSE-2.0 -+ * -+ * Unless required by applicable law or agreed to in writing, software -+ * distributed under the License is distributed on an "AS IS" BASIS, -+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -+ * See the License for the specific language governing permissions and -+ * limitations under the License. -+ */ -+ -+#include -+#include -+ -+#include -+ -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+ -+namespace unwindstack { -+ -+RegsRiscv64::RegsRiscv64() -+ : RegsImpl(RISCV64_REG_MAX, Location(LOCATION_REGISTER, RISCV64_REG_RA)) {} -+ -+ArchEnum RegsRiscv64::Arch() { -+ return ARCH_RISCV64; -+} -+ -+uint64_t RegsRiscv64::pc() { -+ return regs_[RISCV64_REG_PC]; -+} -+ -+uint64_t RegsRiscv64::sp() { -+ return regs_[RISCV64_REG_SP]; -+} -+ -+void RegsRiscv64::set_pc(uint64_t pc) { -+ regs_[RISCV64_REG_PC] = pc; -+} -+ -+void RegsRiscv64::set_sp(uint64_t sp) { -+ regs_[RISCV64_REG_SP] = sp; -+} -+ -+uint64_t RegsRiscv64::GetPcAdjustment(uint64_t rel_pc, Elf*) { -+ if (rel_pc < 8) { -+ return 0; -+ } -+ // For now, just assume no compact branches -+ return 8; -+} -+ -+bool RegsRiscv64::SetPcFromReturnAddress(Memory*) { -+ uint64_t ra = regs_[RISCV64_REG_RA]; -+ if (regs_[RISCV64_REG_PC] == ra) { -+ return false; -+ } -+ -+ regs_[RISCV64_REG_PC] = ra; -+ return true; -+} -+ -+void RegsRiscv64::IterateRegisters(std::function fn) { -+ fn("pc", regs_[RISCV64_REG_PC]); -+ fn("ra", regs_[RISCV64_REG_RA]); -+ fn("sp", regs_[RISCV64_REG_SP]); -+ fn("gp", regs_[RISCV64_REG_GP]); -+ fn("tp", regs_[RISCV64_REG_TP]); -+ fn("t0", regs_[RISCV64_REG_T0]); -+ fn("t1", regs_[RISCV64_REG_T1]); -+ fn("t2", regs_[RISCV64_REG_T2]); -+ fn("t3", regs_[RISCV64_REG_T3]); -+ fn("t4", regs_[RISCV64_REG_T4]); -+ fn("t5", regs_[RISCV64_REG_T5]); -+ fn("t6", regs_[RISCV64_REG_T6]); -+ fn("s0", regs_[RISCV64_REG_S0]); -+ fn("s1", regs_[RISCV64_REG_S1]); -+ fn("s2", regs_[RISCV64_REG_S2]); -+ fn("s3", regs_[RISCV64_REG_S3]); -+ fn("s4", regs_[RISCV64_REG_S4]); -+ fn("s5", regs_[RISCV64_REG_S5]); -+ fn("s6", regs_[RISCV64_REG_S6]); -+ fn("s7", regs_[RISCV64_REG_S7]); -+ fn("s8", regs_[RISCV64_REG_S8]); -+ fn("s9", regs_[RISCV64_REG_S9]); -+ fn("s10", regs_[RISCV64_REG_S10]); -+ fn("s11", regs_[RISCV64_REG_S11]); -+ fn("a0", regs_[RISCV64_REG_A0]); -+ fn("a1", regs_[RISCV64_REG_A1]); -+ fn("a2", regs_[RISCV64_REG_A2]); -+ fn("a3", regs_[RISCV64_REG_A3]); -+ fn("a4", regs_[RISCV64_REG_A4]); -+ fn("a5", regs_[RISCV64_REG_A5]); -+ fn("a6", regs_[RISCV64_REG_A6]); -+ fn("a7", regs_[RISCV64_REG_A7]); -+} -+ -+Regs* RegsRiscv64::Read(void* remote_data) { -+ riscv64_user_regs* user = reinterpret_cast(remote_data); -+ -+ RegsRiscv64* regs = new RegsRiscv64(); -+ memcpy(regs->RawData(), &user->regs[0], RISCV64_REG_MAX * sizeof(uint64_t)); -+ // uint64_t* reg_data = reinterpret_cast(regs->RawData()); -+ return regs; -+} -+ -+Regs* RegsRiscv64::CreateFromUcontext(void* ucontext) { -+ riscv64_ucontext_t* riscv64_ucontext = reinterpret_cast(ucontext); -+ -+ RegsRiscv64* regs = new RegsRiscv64(); -+ memcpy(regs->RawData(), &riscv64_ucontext->uc_mcontext.__gregs[0], -+ RISCV64_REG_MAX * sizeof(uint64_t)); -+ return regs; -+} -+ -+bool RegsRiscv64::StepIfSignalHandler(uint64_t elf_offset, Elf* elf, Memory* process_memory) { -+ uint64_t data; -+ Memory* elf_memory = elf->memory(); -+ // Read from elf memory since it is usually more expensive to read from -+ // process memory. -+ if (!elf_memory->ReadFully(elf_offset, &data, sizeof(data))) { -+ return false; -+ } -+ // Look for the kernel sigreturn function. -+ // __kernel_rt_sigreturn: -+ // li a7, __NR_rt_sigreturn -+ // scall -+ -+ const uint8_t li_scall[] = {0x93, 0x08, 0xb0, 0x08, 0x73, 0x00, 0x00, 0x00}; -+ if (memcmp(&data, &li_scall, 8) != 0) { -+ return false; -+ } -+ -+ // SP + sizeof(siginfo_t) + uc_mcontext offset + PC offset. -+ if (!process_memory->ReadFully(regs_[RISCV64_REG_SP] + 0x80 + 0xb0 + 0x00, regs_.data(), -+ sizeof(uint64_t) * (RISCV64_REG_MAX))) { -+ return false; -+ } -+ return true; -+} -+ -+Regs* RegsRiscv64::Clone() { -+ return new RegsRiscv64(*this); -+} -+ -+} // namespace unwindstack -diff --git a/system/core/libunwindstack/include/unwindstack/Elf.h b/system/core/libunwindstack/include/unwindstack/Elf.h -index 472ed92..88fa0ff 100644 ---- a/system/core/libunwindstack/include/unwindstack/Elf.h -+++ b/system/core/libunwindstack/include/unwindstack/Elf.h -@@ -32,6 +32,10 @@ - #define EM_AARCH64 183 - #endif - -+#if !defined(EM_RISCV) -+#define EM_RISCV 243 -+#endif -+ - namespace unwindstack { - - // Forward declaration. -@@ -46,6 +50,7 @@ enum ArchEnum : uint8_t { - ARCH_X86_64, - ARCH_MIPS, - ARCH_MIPS64, -+ ARCH_RISCV64, - }; - - class Elf { -diff --git a/system/core/libunwindstack/include/unwindstack/MachineRiscv64.h b/system/core/libunwindstack/include/unwindstack/MachineRiscv64.h -new file mode 100644 -index 0000000..397e680 ---- /dev/null -+++ b/system/core/libunwindstack/include/unwindstack/MachineRiscv64.h -@@ -0,0 +1,59 @@ -+/* -+ * Copyright (C) 2022 The Android Open Source Project -+ * -+ * Licensed under the Apache License, Version 2.0 (the "License"); -+ * you may not use this file except in compliance with the License. -+ * You may obtain a copy of the License at -+ * -+ * http://www.apache.org/licenses/LICENSE-2.0 -+ * -+ * Unless required by applicable law or agreed to in writing, software -+ * distributed under the License is distributed on an "AS IS" BASIS, -+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -+ * See the License for the specific language governing permissions and -+ * limitations under the License. -+ */ -+ -+#pragma once -+ -+#include -+ -+namespace unwindstack { -+ -+enum Riscv64Reg : uint16_t { -+ RISCV64_REG_PC, -+ RISCV64_REG_RA, -+ RISCV64_REG_SP, -+ RISCV64_REG_GP, -+ RISCV64_REG_TP, -+ RISCV64_REG_T0, -+ RISCV64_REG_T1, -+ RISCV64_REG_T2, -+ RISCV64_REG_S0, -+ RISCV64_REG_S1, -+ RISCV64_REG_A0, -+ RISCV64_REG_A1, -+ RISCV64_REG_A2, -+ RISCV64_REG_A3, -+ RISCV64_REG_A4, -+ RISCV64_REG_A5, -+ RISCV64_REG_A6, -+ RISCV64_REG_A7, -+ RISCV64_REG_S2, -+ RISCV64_REG_S3, -+ RISCV64_REG_S4, -+ RISCV64_REG_S5, -+ RISCV64_REG_S6, -+ RISCV64_REG_S7, -+ RISCV64_REG_S8, -+ RISCV64_REG_S9, -+ RISCV64_REG_S10, -+ RISCV64_REG_S11, -+ RISCV64_REG_T3, -+ RISCV64_REG_T4, -+ RISCV64_REG_T5, -+ RISCV64_REG_T6, -+ RISCV64_REG_MAX, -+}; -+ -+} // namespace unwindstack -diff --git a/system/core/libunwindstack/include/unwindstack/RegsGetLocal.h b/system/core/libunwindstack/include/unwindstack/RegsGetLocal.h -index f0b5e3a..698eba2 100644 ---- a/system/core/libunwindstack/include/unwindstack/RegsGetLocal.h -+++ b/system/core/libunwindstack/include/unwindstack/RegsGetLocal.h -@@ -81,6 +81,49 @@ inline __attribute__((__always_inline__)) void AsmGetRegs(void* reg_data) { - : "x12", "x13", "memory"); - } - -+#elif defined(__riscv) -+ -+inline __attribute__((__always_inline__)) void AsmGetRegs(void* reg_data) { -+ asm volatile( -+ "1:\n" -+ "sd ra, 8(%[base])\n" -+ "sd sp, 16(%[base])\n" -+ "sd gp, 24(%[base])\n" -+ "sd tp, 32(%[base])\n" -+ "sd t0, 40(%[base])\n" -+ "sd t1, 48(%[base])\n" -+ "sd t2, 56(%[base])\n" -+ "sd s0, 64(%[base])\n" -+ "sd s1, 72(%[base])\n" -+ "sd a0, 80(%[base])\n" -+ "sd a1, 88(%[base])\n" -+ "sd a2, 96(%[base])\n" -+ "sd a3, 104(%[base])\n" -+ "sd a4, 112(%[base])\n" -+ "sd a5, 120(%[base])\n" -+ "sd a6, 128(%[base])\n" -+ "sd a7, 136(%[base])\n" -+ "sd s2, 144(%[base])\n" -+ "sd s3, 152(%[base])\n" -+ "sd s4, 160(%[base])\n" -+ "sd s5, 168(%[base])\n" -+ "sd s6, 176(%[base])\n" -+ "sd s7, 184(%[base])\n" -+ "sd s8, 192(%[base])\n" -+ "sd s9, 200(%[base])\n" -+ "sd s10, 208(%[base])\n" -+ "sd s11, 216(%[base])\n" -+ "sd t3, 224(%[base])\n" -+ "sd t4, 232(%[base])\n" -+ "sd t5, 240(%[base])\n" -+ "sd t6, 248(%[base])\n" -+ "la t1, 1b\n" -+ "sd t1, 0(%[base])\n" -+ : [base] "+r"(reg_data) -+ : -+ : "t1", "memory"); -+} -+ - #elif defined(__i386__) || defined(__x86_64__) || defined(__mips__) - - extern "C" void AsmGetRegs(void* regs); -diff --git a/system/core/libunwindstack/include/unwindstack/RegsRiscv64.h b/system/core/libunwindstack/include/unwindstack/RegsRiscv64.h -new file mode 100644 -index 0000000..eb09397 ---- /dev/null -+++ b/system/core/libunwindstack/include/unwindstack/RegsRiscv64.h -@@ -0,0 +1,59 @@ -+/* -+ * Copyright (C) 2022 The Android Open Source Project -+ * -+ * Licensed under the Apache License, Version 2.0 (the "License"); -+ * you may not use this file except in compliance with the License. -+ * You may obtain a copy of the License at -+ * -+ * http://www.apache.org/licenses/LICENSE-2.0 -+ * -+ * Unless required by applicable law or agreed to in writing, software -+ * distributed under the License is distributed on an "AS IS" BASIS, -+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -+ * See the License for the specific language governing permissions and -+ * limitations under the License. -+ */ -+ -+#pragma once -+ -+#include -+ -+#include -+ -+#include -+#include -+ -+namespace unwindstack { -+ -+// Forward declarations. -+class Memory; -+ -+class RegsRiscv64 : public RegsImpl { -+ public: -+ RegsRiscv64(); -+ virtual ~RegsRiscv64() = default; -+ -+ ArchEnum Arch() override final; -+ -+ uint64_t GetPcAdjustment(uint64_t rel_pc, Elf* elf) override; -+ -+ bool SetPcFromReturnAddress(Memory* process_memory) override; -+ -+ bool StepIfSignalHandler(uint64_t elf_offset, Elf* elf, Memory* process_memory) override; -+ -+ void IterateRegisters(std::function) override final; -+ -+ uint64_t pc() override; -+ uint64_t sp() override; -+ -+ void set_pc(uint64_t pc) override; -+ void set_sp(uint64_t sp) override; -+ -+ Regs* Clone() override final; -+ -+ static Regs* Read(void* data); -+ -+ static Regs* CreateFromUcontext(void* ucontext); -+}; -+ -+} // namespace unwindstack -diff --git a/system/core/libunwindstack/include/unwindstack/UcontextRiscv64.h b/system/core/libunwindstack/include/unwindstack/UcontextRiscv64.h -new file mode 100644 -index 0000000..c6c82b1 ---- /dev/null -+++ b/system/core/libunwindstack/include/unwindstack/UcontextRiscv64.h -@@ -0,0 +1,80 @@ -+/* -+ * Copyright (C) 2014 The Android Open Source Project -+ * All rights reserved. -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * * Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * * Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS -+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED -+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT -+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -+ * SUCH DAMAGE. -+ */ -+ -+#pragma once -+ -+#include -+ -+typedef uint64_t __riscv_mc_gp_state[32]; // unsigned long -+ -+struct __riscv_mc_f_ext_state { -+ uint32_t __f[32]; -+ uint32_t __fcsr; -+}; -+ -+struct __riscv_mc_d_ext_state { -+ uint64_t __f[32]; -+ uint32_t __fcsr; -+}; -+ -+struct __riscv_mc_q_ext_state { -+ uint64_t __f[64] __attribute__((__aligned__(16))); -+ uint32_t __fcsr; -+ uint32_t __reserved[3]; -+}; -+ -+union __riscv_mc_fp_state { -+ struct __riscv_mc_f_ext_state __f; -+ struct __riscv_mc_d_ext_state __d; -+ struct __riscv_mc_q_ext_state __q; -+}; -+ -+struct __riscv_stack_t { -+ uint64_t ss_sp; -+ int32_t ss_flags; -+ uint64_t ss_size; -+}; -+ -+struct riscv64_sigset_t { -+ uint64_t sig; // unsigned long -+}; -+ -+struct riscv64_mcontext_t { -+ __riscv_mc_gp_state __gregs; -+ union __riscv_mc_fp_state __fpregs; -+}; -+ -+struct riscv64_ucontext_t { -+ uint64_t uc_flags; // unsigned long -+ struct riscv64_ucontext_t* uc_link; -+ __riscv_stack_t uc_stack; -+ riscv64_sigset_t uc_sigmask; -+ /* The kernel adds extra padding here to allow sigset_t to grow. */ -+ int8_t __padding[128 - sizeof(riscv64_sigset_t)]; // char -+ riscv64_mcontext_t uc_mcontext; -+}; -diff --git a/system/core/libunwindstack/include/unwindstack/UserRiscv64.h b/system/core/libunwindstack/include/unwindstack/UserRiscv64.h -new file mode 100644 -index 0000000..1e91228 ---- /dev/null -+++ b/system/core/libunwindstack/include/unwindstack/UserRiscv64.h -@@ -0,0 +1,37 @@ -+/* -+ * Copyright (C) 2016 The Android Open Source Project -+ * All rights reserved. -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * * Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * * Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS -+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED -+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT -+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -+ * SUCH DAMAGE. -+ */ -+ -+#pragma once -+ -+namespace unwindstack { -+ -+struct riscv64_user_regs { -+ uint64_t regs[32]; -+}; -+ -+} // namespace unwindstack -diff --git a/system/core/libunwindstack/tools/unwind.cpp b/system/core/libunwindstack/tools/unwind.cpp -index 1812e50..ae20891 100644 ---- a/system/core/libunwindstack/tools/unwind.cpp -+++ b/system/core/libunwindstack/tools/unwind.cpp -@@ -83,6 +83,9 @@ void DoUnwind(pid_t pid) { - case unwindstack::ARCH_MIPS64: - printf("mips64"); - break; -+ case unwindstack::ARCH_RISCV64: -+ printf("riscv64"); -+ break; - default: - printf("unknown\n"); - return; -diff --git a/system/core/libunwindstack/tools/unwind_symbols.cpp b/system/core/libunwindstack/tools/unwind_symbols.cpp -index 8df2284..976db56 100644 ---- a/system/core/libunwindstack/tools/unwind_symbols.cpp -+++ b/system/core/libunwindstack/tools/unwind_symbols.cpp -@@ -77,6 +77,9 @@ int main(int argc, char** argv) { - case EM_AARCH64: - printf("ABI: arm64\n"); - break; -+ case EM_RISCV: -+ printf("ABI: riscv64\n"); -+ break; - case EM_386: - printf("ABI: x86\n"); - break; diff --git a/meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/debian/Added-missing-headers.patch b/meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/debian/Added-missing-headers.patch deleted file mode 100644 index d827d7d3c2..0000000000 --- a/meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/debian/Added-missing-headers.patch +++ /dev/null @@ -1,46 +0,0 @@ -Upstream-Status: Pending - -Description: Added missing headers causing compile errors -Author: Umang Parmar -Forwarded: not-needed - ---- a/system/core/adb/sysdeps/posix/network.cpp -+++ b/system/core/adb/sysdeps/posix/network.cpp -@@ -22,6 +22,7 @@ - #include - - #include -+#include - - #include - #include ---- a/system/core/base/file.cpp -+++ b/system/core/base/file.cpp -@@ -26,6 +26,7 @@ - #include - #include - #include -+#include - - #include - #include ---- a/system/core/libbacktrace/BacktraceMap.cpp -+++ b/system/core/libbacktrace/BacktraceMap.cpp -@@ -21,6 +21,7 @@ - #include - #include - #include -+#include - - #include - ---- a/system/core/libbacktrace/UnwindStackMap.cpp -+++ b/system/core/libbacktrace/UnwindStackMap.cpp -@@ -20,6 +20,7 @@ - - #include - #include -+#include - - #include - #include diff --git a/meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/debian/Nonnull.patch b/meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/debian/Nonnull.patch deleted file mode 100644 index 54bd52c61a..0000000000 --- a/meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/debian/Nonnull.patch +++ /dev/null @@ -1,22 +0,0 @@ -Upstream-Status: Pending - -Description: Bring Clang's _Nonnull keyword to GCC -Author: Kai-Chung Yan -Forwarded: not-needed ---- a/system/core/adb/sysdeps.h -+++ b/system/core/adb/sysdeps.h -@@ -40,11 +40,12 @@ - #include "sysdeps/network.h" - #include "sysdeps/stat.h" - -+#define _Nonnull -+#define _Nullable -+ - #ifdef _WIN32 - - // Clang-only nullability specifiers --#define _Nonnull --#define _Nullable - - #include - #include diff --git a/meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/debian/Vector-cast.patch b/meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/debian/Vector-cast.patch deleted file mode 100644 index b2881e0213..0000000000 --- a/meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/debian/Vector-cast.patch +++ /dev/null @@ -1,16 +0,0 @@ -Upstream-Status: Pending - -Description: Fix the weird error by GCC7 that fails to match the correct parent method. -Author: Kai-Chung Yan -Forwarded: not-needed ---- a/system/core/libutils/include/utils/Vector.h -+++ b/system/core/libutils/include/utils/Vector.h -@@ -256,7 +256,7 @@ - - template inline - const Vector& Vector::operator = (const Vector& rhs) const { -- VectorImpl::operator = (static_cast(rhs)); -+ VectorImpl::operator = (rhs); - return *this; - } - diff --git a/meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/debian/add-missing-headers.patch b/meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/debian/add-missing-headers.patch deleted file mode 100644 index 681d2c6553..0000000000 --- a/meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/debian/add-missing-headers.patch +++ /dev/null @@ -1,43 +0,0 @@ -Upstream-Status: Pending - -Forwarded: not-needed ---- a/system/core/fs_mgr/liblp/reader.cpp -+++ b/system/core/fs_mgr/liblp/reader.cpp -@@ -22,6 +22,7 @@ - #include - - #include -+#include - - #include - #include ---- a/system/core/fs_mgr/liblp/writer.cpp -+++ b/system/core/fs_mgr/liblp/writer.cpp -@@ -21,6 +21,7 @@ - #include - - #include -+#include - - #include - #include ---- a/system/core/liblog/logger_write.cpp -+++ b/system/core/liblog/logger_write.cpp -@@ -27,6 +27,7 @@ - #include - #endif - -+#include - #include - - #include ---- a/system/core/libziparchive/zip_archive_stream_entry.cc -+++ b/system/core/libziparchive/zip_archive_stream_entry.cc -@@ -23,6 +23,7 @@ - #include - #include - -+#include - #include - #include - diff --git a/meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/debian/external/libunwind/20150704-CVE-2015-3239_dwarf_i.h.patch b/meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/debian/external/libunwind/20150704-CVE-2015-3239_dwarf_i.h.patch deleted file mode 100644 index e8e216161e..0000000000 --- a/meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/debian/external/libunwind/20150704-CVE-2015-3239_dwarf_i.h.patch +++ /dev/null @@ -1,15 +0,0 @@ -Upstream-Status: Pending - -Description: Off-by-one error in the dwarf_to_unw_regnum function in include/dwarf_i.h in -libunwind 1.1 allows local users to have unspecified impact via invalid dwarf opcodes. ---- a/external/libunwind/include/dwarf_i.h -+++ b/external/libunwind/include/dwarf_i.h -@@ -20,7 +20,7 @@ - extern const uint8_t dwarf_to_unw_regnum_map[DWARF_REGNUM_MAP_LENGTH]; - /* REG is evaluated multiple times; it better be side-effects free! */ - # define dwarf_to_unw_regnum(reg) \ -- (((reg) <= DWARF_REGNUM_MAP_LENGTH) ? dwarf_to_unw_regnum_map[reg] : 0) -+ (((reg) < DWARF_REGNUM_MAP_LENGTH) ? dwarf_to_unw_regnum_map[reg] : 0) - #endif - - #ifdef UNW_LOCAL_ONLY diff --git a/meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/debian/external/libunwind/legacy_built-in_sync_functions.patch b/meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/debian/external/libunwind/legacy_built-in_sync_functions.patch deleted file mode 100644 index a04a887c68..0000000000 --- a/meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/debian/external/libunwind/legacy_built-in_sync_functions.patch +++ /dev/null @@ -1,28 +0,0 @@ -Upstream-Status: Pending - -Description: Replace the legacy __sync built-in functions with __atomic ones - libunwind uses the built-in __sync_* functions which are deprecated by GCC and - should be replaced by __atomic_* ones. See the official manuals [1]. - . - The legacy __sync functions do not require to specify the memory order but - __atomic ones do, so we choose the strongest one: __ATOMIC_SEQ_CST. - . - We do this because __sync_fetch_and_add() is not supported on armel. - . - [1]: https://gcc.gnu.org/onlinedocs/gcc/_005f_005fsync-Builtins.html -Author: Kai-Chung Yan () -Last-Update: 2016-10-04 -Forwarded: not-needed ---- a/external/libunwind/include/libunwind_i.h -+++ b/external/libunwind/include/libunwind_i.h -@@ -155,8 +155,8 @@ cmpxchg_ptr (void *addr, void *old, void - u.vp = addr; - return __sync_bool_compare_and_swap(u.vlp, (long) old, (long) new); - } --# define fetch_and_add1(_ptr) __sync_fetch_and_add(_ptr, 1) --# define fetch_and_add(_ptr, value) __sync_fetch_and_add(_ptr, value) -+# define fetch_and_add1(_ptr) __atomic_fetch_add(_ptr, 1, __ATOMIC_SEQ_CST) -+# define fetch_and_add(_ptr, value) __atomic_fetch_add(_ptr, value, __ATOMIC_SEQ_CST) - # define HAVE_CMPXCHG - # define HAVE_FETCH_AND_ADD - #endif diff --git a/meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/debian/external/libunwind/libunwind-fix-strchr-conformance-to-ISO-C23.patch b/meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/debian/external/libunwind/libunwind-fix-strchr-conformance-to-ISO-C23.patch deleted file mode 100644 index 4da65ea285..0000000000 --- a/meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/debian/external/libunwind/libunwind-fix-strchr-conformance-to-ISO-C23.patch +++ /dev/null @@ -1,27 +0,0 @@ -From d91f5324f809c3a5b0343927716e4b99bc31db53 Mon Sep 17 00:00:00 2001 -From: Viswanath Kraleti -Date: Fri, 13 Mar 2026 18:57:36 +0530 -Subject: [PATCH] libunwind: fix strchr() conformance to ISO C23 - -Fix uses of strchr() to conform to ISO C23, supported since glibc-2.43 - -Signed-off-by: Viswanath Kraleti -Upstream-Status: Pending ---- - external/libunwind/src/dwarf/Gfind_proc_info-lsb.c | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -diff --git a/external/libunwind/src/dwarf/Gfind_proc_info-lsb.c b/external/libunwind/src/dwarf/Gfind_proc_info-lsb.c -index 77ed3d09..37eadf52 100644 ---- a/external/libunwind/src/dwarf/Gfind_proc_info-lsb.c -+++ b/external/libunwind/src/dwarf/Gfind_proc_info-lsb.c -@@ -248,7 +248,8 @@ load_debug_frame (const char *file, char **buf, size_t *bufsize, - - if (*buf == NULL && linkbuf != NULL && memchr (linkbuf, 0, linksize) != NULL) - { -- char *newname, *basedir, *p; -+ char *newname, *basedir; -+ const char *p; - static const char *debugdir = "/usr/lib/debug"; - int ret; - diff --git a/meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/debian/external/libunwind/libunwind-guard-unreachable-macro-to-avoid-redefinit.patch b/meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/debian/external/libunwind/libunwind-guard-unreachable-macro-to-avoid-redefinit.patch deleted file mode 100644 index 1e0f15ddf0..0000000000 --- a/meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/debian/external/libunwind/libunwind-guard-unreachable-macro-to-avoid-redefinit.patch +++ /dev/null @@ -1,42 +0,0 @@ -From e64495a109eefaf87235729f4dd79fc9121c16a6 Mon Sep 17 00:00:00 2001 -From: Sasi Kumar Maddineni -Date: Mon, 27 Oct 2025 19:39:05 +0530 -Subject: [PATCH] libunwind: guard unreachable() macro to avoid redefinition - with stddef.h - -The build fails due to a macro redefinition conflict for `unreachable()`. -GCC 15.2.0 defines `unreachable()` in `stddef.h`, and `libunwind_i.h` also -defines it based on the presence of `HAVE__BUILTIN_UNREACHABLE`. This causes -a redefinition error when building with `-Werror`. - -Added a guard around the `unreachable()` macro definition in `libunwind_i.h` -to ensure it is only defined if not already present. - -Upstream-Status: Pending - -Signed-off-by: Sasi Kumar Maddineni ---- - external/libunwind/include/libunwind_i.h | 2 ++ - 1 file changed, 2 insertions(+) - -diff --git a/external/libunwind/include/libunwind_i.h b/external/libunwind/include/libunwind_i.h -index c06912a6..59a462df 100644 ---- a/external/libunwind/include/libunwind_i.h -+++ b/external/libunwind/include/libunwind_i.h -@@ -88,11 +88,13 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ - # endif - #endif - -+#if !defined(unreachable) - #if defined(HAVE__BUILTIN_UNREACHABLE) - # define unreachable() __builtin_unreachable() - #else - # define unreachable() do { } while (1) - #endif -+#endif - - #ifdef DEBUG - # define UNW_DEBUG 1 --- -2.34.1 - diff --git a/meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/debian/external/libunwind/user_pt_regs.patch b/meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/debian/external/libunwind/user_pt_regs.patch deleted file mode 100644 index 35df944d1c..0000000000 --- a/meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/debian/external/libunwind/user_pt_regs.patch +++ /dev/null @@ -1,26 +0,0 @@ -Upstream-Status: Pending - -Author: Kai-Chung Yan -Last-Update: 2016-08-24 -Description: Manual definition of struct user_pt_regs - On ARM64, libunwind uses struct user_pt_regs which is not defined in - anywhere, which causes FTBFS. -Forwarded: not-needed ---- a/external/libunwind/src/ptrace/_UPT_access_reg.c -+++ b/external/libunwind/src/ptrace/_UPT_access_reg.c -@@ -26,6 +26,15 @@ WITH THE SOFTWARE OR THE USE OR OTHER DE - - #include "_UPT_internal.h" - -+#if defined(__aarch64__) -+ struct user_pt_regs { -+ __u64 regs[31]; -+ __u64 sp; -+ __u64 pc; -+ __u64 pstate; -+ }; -+#endif -+ - #if UNW_TARGET_IA64 - # include - # ifdef HAVE_ASM_PTRACE_OFFSETS_H diff --git a/meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/debian/fix-attribute-issue-with-gcc.patch b/meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/debian/fix-attribute-issue-with-gcc.patch deleted file mode 100644 index 441031f536..0000000000 --- a/meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/debian/fix-attribute-issue-with-gcc.patch +++ /dev/null @@ -1,19 +0,0 @@ -Upstream-Status: Pending - -Description: remove clang-ism -Forwarded: not-needed - ---- a/system/core/base/include/android-base/logging.h -+++ b/system/core/base/include/android-base/logging.h -@@ -451,10 +451,7 @@ - // -Wno-user-defined-warnings to CPPFLAGS. - #pragma clang diagnostic push - #pragma clang diagnostic ignored "-Wgcc-compat" --#define OSTREAM_STRING_POINTER_USAGE_WARNING \ -- __attribute__((diagnose_if(true, "Unexpected logging of string pointer", "warning"))) --inline OSTREAM_STRING_POINTER_USAGE_WARNING --std::ostream& operator<<(std::ostream& stream, const std::string* string_pointer) { -+inline std::ostream& operator<<(std::ostream& stream, const std::string* string_pointer) { - return stream << static_cast(string_pointer); - } - #pragma clang diagnostic pop diff --git a/meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/debian/fix-build-on-non-x86.patch b/meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/debian/fix-build-on-non-x86.patch deleted file mode 100644 index b1caa60c4a..0000000000 --- a/meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/debian/fix-build-on-non-x86.patch +++ /dev/null @@ -1,26 +0,0 @@ -Upstream-Status: Pending - -Description: non-x86 arches do not have PAGE_SIZE -Forwarded: not-needed ---- a/system/core/base/cmsg.cpp -+++ b/system/core/base/cmsg.cpp -@@ -33,7 +33,8 @@ - const std::vector& fds) { - size_t cmsg_space = CMSG_SPACE(sizeof(int) * fds.size()); - size_t cmsg_len = CMSG_LEN(sizeof(int) * fds.size()); -- if (cmsg_space >= PAGE_SIZE) { -+ size_t pagesize = static_cast(sysconf(_SC_PAGE_SIZE)); -+ if (cmsg_space >= pagesize) { - errno = ENOMEM; - return -1; - } -@@ -75,7 +76,8 @@ - fds->clear(); - - size_t cmsg_space = CMSG_SPACE(sizeof(int) * max_fds); -- if (cmsg_space >= PAGE_SIZE) { -+ size_t pagesize = static_cast(sysconf(_SC_PAGE_SIZE)); -+ if (cmsg_space >= pagesize) { - errno = ENOMEM; - return -1; - } diff --git a/meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/debian/fix-gettid-exception-declaration.patch b/meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/debian/fix-gettid-exception-declaration.patch deleted file mode 100644 index 5f24d0b4a0..0000000000 --- a/meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/debian/fix-gettid-exception-declaration.patch +++ /dev/null @@ -1,26 +0,0 @@ -Upstream-Status: Pending - -Description: get libcutils building -Forwarded: not-needed ---- a/system/core/libcutils/include/cutils/threads.h -+++ b/system/core/libcutils/include/cutils/threads.h -@@ -33,7 +33,7 @@ - // Deprecated: use android::base::GetThreadId instead, which doesn't truncate on Mac/Windows. - // - --extern pid_t gettid(); -+extern pid_t gettid(void) __THROW; - - // - // Deprecated: use `_Thread_local` in C or `thread_local` in C++. ---- a/system/core/libcutils/threads.cpp -+++ b/system/core/libcutils/threads.cpp -@@ -33,7 +33,7 @@ - - // No definition needed for Android because we'll just pick up bionic's copy. - #ifndef __ANDROID__ --pid_t gettid() { -+pid_t gettid(void) __THROW { - #if defined(__APPLE__) - uint64_t tid; - pthread_threadid_np(NULL, &tid); diff --git a/meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/debian/fix-standard-namespace-errors.patch b/meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/debian/fix-standard-namespace-errors.patch deleted file mode 100644 index 4380308f13..0000000000 --- a/meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/debian/fix-standard-namespace-errors.patch +++ /dev/null @@ -1,24 +0,0 @@ -Upstream-Status: Pending - -Description: Add missing 'std::' scope identifiers. -Forwarded: not-needed ---- a/system/core/libunwindstack/include/unwindstack/DwarfMemory.h -+++ b/system/core/libunwindstack/include/unwindstack/DwarfMemory.h -@@ -29,7 +29,7 @@ - DwarfMemory(Memory* memory) : memory_(memory) {} - virtual ~DwarfMemory() = default; - -- bool ReadBytes(void* dst, size_t num_bytes); -+ bool ReadBytes(void* dst, std::size_t num_bytes); - - template - bool ReadSigned(uint64_t* value); -@@ -39,7 +39,7 @@ - bool ReadSLEB128(int64_t* value); - - template -- size_t GetEncodedSize(uint8_t encoding); -+ std::size_t GetEncodedSize(uint8_t encoding); - - bool AdjustEncodedValue(uint8_t encoding, uint64_t* value); - diff --git a/meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/debian/hard-code-build-number.patch b/meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/debian/hard-code-build-number.patch deleted file mode 100644 index 4d7323bd2f..0000000000 --- a/meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/debian/hard-code-build-number.patch +++ /dev/null @@ -1,46 +0,0 @@ -Upstream-Status: Pending - -Description: just hard code rather than deal with circular deps -Forwarded: not-needed ---- a/system/core/adb/adb.cpp -+++ b/system/core/adb/adb.cpp -@@ -44,8 +44,6 @@ - #include - #include - #include --#include --#include - - #include "adb_auth.h" - #include "adb_io.h" -@@ -69,7 +67,7 @@ - "Version %s-%s\n" - "Installed as %s\n", - ADB_VERSION_MAJOR, ADB_VERSION_MINOR, ADB_SERVER_VERSION, -- PLATFORM_TOOLS_VERSION, android::build::GetBuildNumber().c_str(), -+ PLATFORM_TOOLS_VERSION, "debian", - android::base::GetExecutablePath().c_str()); - } - ---- a/system/core/fastboot/fastboot.cpp -+++ b/system/core/fastboot/fastboot.cpp -@@ -59,10 +59,8 @@ - #include - #include - #include --#include - #include - #include --#include - #include - #include - -@@ -1680,7 +1678,7 @@ - setvbuf(stdout, nullptr, _IONBF, 0); - setvbuf(stderr, nullptr, _IONBF, 0); - } else if (name == "version") { -- fprintf(stdout, "fastboot version %s-%s\n", PLATFORM_TOOLS_VERSION, android::build::GetBuildNumber().c_str()); -+ fprintf(stdout, "fastboot version %s-%s\n", PLATFORM_TOOLS_VERSION, "debian"); - fprintf(stdout, "Installed as %s\n", android::base::GetExecutablePath().c_str()); - return 0; - #if !defined(_WIN32) diff --git a/meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/debian/libusb-header-path.patch b/meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/debian/libusb-header-path.patch deleted file mode 100644 index 122bd70e7d..0000000000 --- a/meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/debian/libusb-header-path.patch +++ /dev/null @@ -1,18 +0,0 @@ -Upstream-Status: Pending - -Description: libusb.h comes from different location -Author: Umang Parmar -Forwarded: not-needed -Last-Update: 2018-05-26 - ---- a/system/core/adb/client/usb_libusb.cpp -+++ b/system/core/adb/client/usb_libusb.cpp -@@ -30,7 +30,7 @@ - #include - #include - --#include -+#include - - #include - #include diff --git a/meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/debian/move-log-file-to-proper-dir.patch b/meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/debian/move-log-file-to-proper-dir.patch deleted file mode 100644 index e8494ab433..0000000000 --- a/meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/debian/move-log-file-to-proper-dir.patch +++ /dev/null @@ -1,20 +0,0 @@ -Upstream-Status: Pending - -Description: Update log file directory. -Author: Umang Parmar -Last Updated: 2018-05-17 - ---- a/system/core/adb/adb_utils.cpp -+++ b/system/core/adb/adb_utils.cpp -@@ -339,6 +339,11 @@ - - return temp_path_utf8 + log_name; - #else -+ std::string log_dir = android::base::StringPrintf("/run/user/%u/adb.log", getuid()); -+ struct stat st = {0}; -+ if (stat(log_dir.c_str(), &st) == 0) { -+ return log_dir; -+ } - const char* tmp_dir = getenv("TMPDIR"); - if (tmp_dir == nullptr) tmp_dir = "/tmp"; - return android::base::StringPrintf("%s/adb.%u.log", tmp_dir, getuid()); diff --git a/meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/debian/simg_dump-python3.patch b/meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/debian/simg_dump-python3.patch deleted file mode 100644 index 6664dc2aa5..0000000000 --- a/meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/debian/simg_dump-python3.patch +++ /dev/null @@ -1,64 +0,0 @@ -Description: Port simg_dump to Python 3. -Author: Antonio Russo -Forwarded: not-needed -Last-Update: 2019-01-05 -Origin: https://bugs.debian.org/945646 - ---- -Upstream-Status: Pending - -Index: android-platform-tools/system/core/libsparse/simg_dump.py -=================================================================== ---- android-platform-tools.orig/system/core/libsparse/simg_dump.py -+++ android-platform-tools/system/core/libsparse/simg_dump.py -@@ -1,4 +1,4 @@ --#! /usr/bin/env python -+#! /usr/bin/env python3 - - # Copyright (C) 2012 The Android Open Source Project - # -@@ -14,7 +14,7 @@ - # See the License for the specific language governing permissions and - # limitations under the License. - --from __future__ import print_function -+ - import csv - import getopt - import hashlib -@@ -47,7 +47,7 @@ def main(): - opts, args = getopt.getopt(sys.argv[1:], - "vsc:", - ["verbose", "showhash", "csvfile"]) -- except getopt.GetoptError, e: -+ except getopt.GetoptError as e: - print(e) - usage(me) - for o, a in opts: -@@ -66,7 +66,7 @@ def main(): - usage(me) - - if csvfilename: -- csvfile = open(csvfilename, "wb") -+ csvfile = open(csvfilename, "w", newline='') - csvwriter = csv.writer(csvfile) - - output = verbose or csvfilename or showhash -@@ -121,7 +121,7 @@ def main(): - "output offset", "output blocks", "type", "hash"]) - - offset = 0 -- for i in xrange(1, total_chunks + 1): -+ for i in range(1, total_chunks + 1): - header_bin = FH.read(12) - header = struct.unpack("<2H2I", header_bin) - chunk_type = header[0] -@@ -160,7 +160,7 @@ def main(): - if showhash: - h = hashlib.sha1() - data = fill_bin * (blk_sz / 4); -- for block in xrange(chunk_sz): -+ for block in range(chunk_sz): - h.update(data) - curhash = h.hexdigest() - elif chunk_type == 0xCAC3: diff --git a/meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/debian/stdatomic.patch b/meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/debian/stdatomic.patch deleted file mode 100644 index e11f3cc783..0000000000 --- a/meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/debian/stdatomic.patch +++ /dev/null @@ -1,66 +0,0 @@ -Upstream-Status: Pending - -Description: Fix incompatibility between and - This 2 headers combined will cause errors for both GCC and Clang. This patch - makes sure only one of them is present at any time. -Bug: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60932 -Bug: https://reviews.llvm.org/D45470 ---- a/system/core/libcutils/include/cutils/trace.h -+++ b/system/core/libcutils/include/cutils/trace.h -@@ -18,7 +18,14 @@ - #define _LIBS_CUTILS_TRACE_H - - #include -+#ifdef __cplusplus -+#include -+using std::atomic_bool; -+using std::atomic_load_explicit; -+using std::memory_order_acquire; -+#else - #include -+#endif - #include - #include - #include ---- a/system/core/libcutils/include/cutils/atomic.h -+++ b/system/core/libcutils/include/cutils/atomic.h -@@ -19,7 +19,23 @@ - - #include - #include -+#ifdef __cplusplus -+#include -+using std::atomic_compare_exchange_strong_explicit; -+using std::atomic_fetch_add_explicit; -+using std::atomic_fetch_or_explicit; -+using std::atomic_fetch_sub_explicit; -+using std::atomic_int_least32_t; -+using std::atomic_load_explicit; -+using std::atomic_store_explicit; -+using std::atomic_thread_fence; -+using std::memory_order::memory_order_acquire; -+using std::memory_order::memory_order_relaxed; -+using std::memory_order::memory_order_release; -+using std::memory_order::memory_order_seq_cst; -+#else - #include -+#endif - - #ifndef ANDROID_ATOMIC_INLINE - #define ANDROID_ATOMIC_INLINE static inline ---- a/system/core/liblog/logger.h -+++ b/system/core/liblog/logger.h -@@ -16,7 +16,13 @@ - - #pragma once - -+#ifdef __cplusplus -+#include -+using std::atomic_int; -+using std::atomic_uintptr_t; -+#else - #include -+#endif - #include - - #include diff --git a/meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/debian/stub-out-fastdeploy.patch b/meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/debian/stub-out-fastdeploy.patch deleted file mode 100644 index d86ef230f7..0000000000 --- a/meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/debian/stub-out-fastdeploy.patch +++ /dev/null @@ -1,95 +0,0 @@ -Upstream-Status: Pending - -Description: Defer packaging fastdeploy with adb for 29.x.x tags. -Forwarded: not-needed ---- a/system/core/adb/client/commandline.cpp -+++ b/system/core/adb/client/commandline.cpp -@@ -59,7 +59,6 @@ - #include "bugreport.h" - #include "client/file_sync_client.h" - #include "commandline.h" --#include "fastdeploy.h" - #include "services.h" - #include "shell_protocol.h" - #include "sysdeps/chrono.h" ---- a/system/core/adb/client/adb_install.cpp -+++ b/system/core/adb/client/adb_install.cpp -@@ -35,7 +35,6 @@ - #include "adb_utils.h" - #include "client/file_sync_client.h" - #include "commandline.h" --#include "fastdeploy.h" - - static constexpr int kFastDeployMinApi = 24; - -@@ -167,14 +166,6 @@ - } - - if (use_fastdeploy) { -- auto metadata = extract_metadata(file); -- if (metadata.has_value()) { -- // pass all but 1st (command) and last (apk path) parameters through to pm for -- // session creation -- std::vector pm_args{argv + 1, argv + argc - 1}; -- auto patchFd = install_patch(pm_args.size(), pm_args.data()); -- return stream_patch(file, std::move(metadata.value()), std::move(patchFd)); -- } - } - - struct stat sb; -@@ -267,16 +258,6 @@ - argv[last_apk] = apk_dest.c_str(); /* destination name, not source location */ - - if (use_fastdeploy) { -- auto metadata = extract_metadata(apk_file[0]); -- if (metadata.has_value()) { -- auto patchFd = apply_patch_on_device(apk_dest.c_str()); -- int status = stream_patch(apk_file[0], std::move(metadata.value()), std::move(patchFd)); -- -- result = pm_command(argc, argv); -- delete_device_file(apk_dest); -- -- return status; -- } - } - - if (do_sync_push(apk_file, apk_dest.c_str(), false)) { -@@ -292,7 +273,6 @@ - InstallMode installMode = INSTALL_DEFAULT; - bool use_fastdeploy = false; - bool is_reinstall = false; -- FastDeploy_AgentUpdateStrategy agent_update_strategy = FastDeploy_AgentUpdateDifferentVersion; - - for (int i = 1; i < argc; i++) { - if (!strcmp(argv[i], "--streaming")) { -@@ -313,13 +293,10 @@ - use_fastdeploy = false; - } else if (!strcmp(argv[i], "--force-agent")) { - processedArgIndicies.push_back(i); -- agent_update_strategy = FastDeploy_AgentUpdateAlways; - } else if (!strcmp(argv[i], "--date-check-agent")) { - processedArgIndicies.push_back(i); -- agent_update_strategy = FastDeploy_AgentUpdateNewerTimeStamp; - } else if (!strcmp(argv[i], "--version-check-agent")) { - processedArgIndicies.push_back(i); -- agent_update_strategy = FastDeploy_AgentUpdateDifferentVersion; - } - } - -@@ -331,13 +308,11 @@ - error_exit("Attempting to use streaming install on unsupported device"); - } - -- if (use_fastdeploy && get_device_api_level() < kFastDeployMinApi) { -- printf("Fast Deploy is only compatible with devices of API version %d or higher, " -- "ignoring.\n", -- kFastDeployMinApi); -+ if (use_fastdeploy) { -+ printf("Fast Deploy is unavailable in this build of adb, " -+ "ignoring.\n"); - use_fastdeploy = false; - } -- fastdeploy_set_agent_update_strategy(agent_update_strategy); - - std::vector passthrough_argv; - for (int i = 0; i < argc; i++) { diff --git a/meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/debian/system/core/Add-riscv64-support.patch b/meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/debian/system/core/Add-riscv64-support.patch deleted file mode 100644 index 9fd0fa792c..0000000000 --- a/meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/debian/system/core/Add-riscv64-support.patch +++ /dev/null @@ -1,653 +0,0 @@ -From: Guo Ren -Date: Wed, 29 Jun 2022 16:46:46 +0800 -Subject: Add riscv64 support - -This patch contains the dwarf unwind support for 64bit risc-v. - - * DwarfCfa.cpp (cfa_def_cfa_register): setup register if CFA_REG is - not setup for riscv64 - * Elf.cpp (GetRelPc): convert offset to virtual address for riscv64. - * ElfInterface.cpp (GetVirtAddrFromOffset): New for riscv64. - * RegsRiscv64.cpp (StepIfSignalHandler): Fix signal frame check. - libunwindstack/include/unwindstack/ - * ElfInterface.h (GetVirtAddrFromOffset): New for riscv64. - libunwindstack/tests/ - * DwarfCfaTest.cpp (cfa_def_cfa_register): ok for riscv64. - * RegsStepIfSignalHandlerTest.cpp (riscv64_step_if_signal_handler): Fix - testcase for riscv64 - -Test: Builds. -Test: All unit tests pass. - -Signed-off-by: Guo Ren -Signed-off-by: Lifang Xia -Signed-off-by: Mao Han -Change-Id: Ib21ddf23cc83f332af202df7bffcaceec16063e0 ---- -Upstream-Status: Pending - - system/core/libunwindstack/Android.bp | 1 + - system/core/libunwindstack/Elf.cpp | 2 + - system/core/libunwindstack/Regs.cpp | 10 ++ - system/core/libunwindstack/RegsRiscv64.cpp | 156 +++++++++++++++++++++ - .../core/libunwindstack/include/unwindstack/Elf.h | 5 + - .../include/unwindstack/MachineRiscv64.h | 59 ++++++++ - .../include/unwindstack/RegsGetLocal.h | 43 ++++++ - .../include/unwindstack/RegsRiscv64.h | 59 ++++++++ - .../include/unwindstack/UcontextRiscv64.h | 80 +++++++++++ - .../include/unwindstack/UserRiscv64.h | 37 +++++ - system/core/libunwindstack/tools/unwind.cpp | 3 + - .../core/libunwindstack/tools/unwind_symbols.cpp | 3 + - 12 files changed, 458 insertions(+) - create mode 100644 system/core/libunwindstack/RegsRiscv64.cpp - create mode 100644 system/core/libunwindstack/include/unwindstack/MachineRiscv64.h - create mode 100644 system/core/libunwindstack/include/unwindstack/RegsRiscv64.h - create mode 100644 system/core/libunwindstack/include/unwindstack/UcontextRiscv64.h - create mode 100644 system/core/libunwindstack/include/unwindstack/UserRiscv64.h - -diff --git a/system/core/libunwindstack/Android.bp b/system/core/libunwindstack/Android.bp -index 3695f72..f1f9c68 100644 ---- a/system/core/libunwindstack/Android.bp -+++ b/system/core/libunwindstack/Android.bp -@@ -70,6 +70,7 @@ cc_library { - "RegsArm64.cpp", - "RegsX86.cpp", - "RegsX86_64.cpp", -+ "RegsRiscv64.cpp", - "RegsMips.cpp", - "RegsMips64.cpp", - "Unwinder.cpp", -diff --git a/system/core/libunwindstack/Elf.cpp b/system/core/libunwindstack/Elf.cpp -index f01b092..3c2088b 100644 ---- a/system/core/libunwindstack/Elf.cpp -+++ b/system/core/libunwindstack/Elf.cpp -@@ -290,6 +290,8 @@ ElfInterface* Elf::CreateInterfaceFromMemory(Memory* memory) { - arch_ = ARCH_X86_64; - } else if (e_machine == EM_MIPS) { - arch_ = ARCH_MIPS64; -+ } else if (e_machine == EM_RISCV) { -+ arch_ = ARCH_RISCV64; - } else { - // Unsupported. - ALOGI("64 bit elf that is neither aarch64 nor x86_64 nor mips64: e_machine = %d\n", -diff --git a/system/core/libunwindstack/Regs.cpp b/system/core/libunwindstack/Regs.cpp -index c7dec52..447a554 100644 ---- a/system/core/libunwindstack/Regs.cpp -+++ b/system/core/libunwindstack/Regs.cpp -@@ -27,12 +27,14 @@ - #include - #include - #include -+#include - #include - #include - #include - #include - #include - #include -+#include - #include - #include - -@@ -67,6 +69,8 @@ Regs* Regs::RemoteGet(pid_t pid) { - return RegsMips::Read(buffer.data()); - case sizeof(mips64_user_regs): - return RegsMips64::Read(buffer.data()); -+ case sizeof(riscv64_user_regs): -+ return RegsRiscv64::Read(buffer.data()); - } - return nullptr; - } -@@ -85,6 +89,8 @@ Regs* Regs::CreateFromUcontext(ArchEnum arch, void* ucontext) { - return RegsMips::CreateFromUcontext(ucontext); - case ARCH_MIPS64: - return RegsMips64::CreateFromUcontext(ucontext); -+ case ARCH_RISCV64: -+ return RegsRiscv64::CreateFromUcontext(ucontext); - case ARCH_UNKNOWN: - default: - return nullptr; -@@ -104,6 +110,8 @@ ArchEnum Regs::CurrentArch() { - return ARCH_MIPS; - #elif defined(__mips__) && defined(__LP64__) - return ARCH_MIPS64; -+#elif defined(__riscv) -+ return ARCH_RISCV64; - #else - abort(); - #endif -@@ -123,6 +131,8 @@ Regs* Regs::CreateFromLocal() { - regs = new RegsMips(); - #elif defined(__mips__) && defined(__LP64__) - regs = new RegsMips64(); -+#elif defined(__riscv) -+ regs = new RegsRiscv64(); - #else - abort(); - #endif -diff --git a/system/core/libunwindstack/RegsRiscv64.cpp b/system/core/libunwindstack/RegsRiscv64.cpp -new file mode 100644 -index 0000000..887762a ---- /dev/null -+++ b/system/core/libunwindstack/RegsRiscv64.cpp -@@ -0,0 +1,156 @@ -+/* -+ * Copyright (C) 2022 The Android Open Source Project -+ * -+ * Licensed under the Apache License, Version 2.0 (the "License"); -+ * you may not use this file except in compliance with the License. -+ * You may obtain a copy of the License at -+ * -+ * http://www.apache.org/licenses/LICENSE-2.0 -+ * -+ * Unless required by applicable law or agreed to in writing, software -+ * distributed under the License is distributed on an "AS IS" BASIS, -+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -+ * See the License for the specific language governing permissions and -+ * limitations under the License. -+ */ -+ -+#include -+#include -+ -+#include -+ -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+ -+namespace unwindstack { -+ -+RegsRiscv64::RegsRiscv64() -+ : RegsImpl(RISCV64_REG_MAX, Location(LOCATION_REGISTER, RISCV64_REG_RA)) {} -+ -+ArchEnum RegsRiscv64::Arch() { -+ return ARCH_RISCV64; -+} -+ -+uint64_t RegsRiscv64::pc() { -+ return regs_[RISCV64_REG_PC]; -+} -+ -+uint64_t RegsRiscv64::sp() { -+ return regs_[RISCV64_REG_SP]; -+} -+ -+void RegsRiscv64::set_pc(uint64_t pc) { -+ regs_[RISCV64_REG_PC] = pc; -+} -+ -+void RegsRiscv64::set_sp(uint64_t sp) { -+ regs_[RISCV64_REG_SP] = sp; -+} -+ -+uint64_t RegsRiscv64::GetPcAdjustment(uint64_t rel_pc, Elf*) { -+ if (rel_pc < 8) { -+ return 0; -+ } -+ // For now, just assume no compact branches -+ return 8; -+} -+ -+bool RegsRiscv64::SetPcFromReturnAddress(Memory*) { -+ uint64_t ra = regs_[RISCV64_REG_RA]; -+ if (regs_[RISCV64_REG_PC] == ra) { -+ return false; -+ } -+ -+ regs_[RISCV64_REG_PC] = ra; -+ return true; -+} -+ -+void RegsRiscv64::IterateRegisters(std::function fn) { -+ fn("pc", regs_[RISCV64_REG_PC]); -+ fn("ra", regs_[RISCV64_REG_RA]); -+ fn("sp", regs_[RISCV64_REG_SP]); -+ fn("gp", regs_[RISCV64_REG_GP]); -+ fn("tp", regs_[RISCV64_REG_TP]); -+ fn("t0", regs_[RISCV64_REG_T0]); -+ fn("t1", regs_[RISCV64_REG_T1]); -+ fn("t2", regs_[RISCV64_REG_T2]); -+ fn("t3", regs_[RISCV64_REG_T3]); -+ fn("t4", regs_[RISCV64_REG_T4]); -+ fn("t5", regs_[RISCV64_REG_T5]); -+ fn("t6", regs_[RISCV64_REG_T6]); -+ fn("s0", regs_[RISCV64_REG_S0]); -+ fn("s1", regs_[RISCV64_REG_S1]); -+ fn("s2", regs_[RISCV64_REG_S2]); -+ fn("s3", regs_[RISCV64_REG_S3]); -+ fn("s4", regs_[RISCV64_REG_S4]); -+ fn("s5", regs_[RISCV64_REG_S5]); -+ fn("s6", regs_[RISCV64_REG_S6]); -+ fn("s7", regs_[RISCV64_REG_S7]); -+ fn("s8", regs_[RISCV64_REG_S8]); -+ fn("s9", regs_[RISCV64_REG_S9]); -+ fn("s10", regs_[RISCV64_REG_S10]); -+ fn("s11", regs_[RISCV64_REG_S11]); -+ fn("a0", regs_[RISCV64_REG_A0]); -+ fn("a1", regs_[RISCV64_REG_A1]); -+ fn("a2", regs_[RISCV64_REG_A2]); -+ fn("a3", regs_[RISCV64_REG_A3]); -+ fn("a4", regs_[RISCV64_REG_A4]); -+ fn("a5", regs_[RISCV64_REG_A5]); -+ fn("a6", regs_[RISCV64_REG_A6]); -+ fn("a7", regs_[RISCV64_REG_A7]); -+} -+ -+Regs* RegsRiscv64::Read(void* remote_data) { -+ riscv64_user_regs* user = reinterpret_cast(remote_data); -+ -+ RegsRiscv64* regs = new RegsRiscv64(); -+ memcpy(regs->RawData(), &user->regs[0], RISCV64_REG_MAX * sizeof(uint64_t)); -+ // uint64_t* reg_data = reinterpret_cast(regs->RawData()); -+ return regs; -+} -+ -+Regs* RegsRiscv64::CreateFromUcontext(void* ucontext) { -+ riscv64_ucontext_t* riscv64_ucontext = reinterpret_cast(ucontext); -+ -+ RegsRiscv64* regs = new RegsRiscv64(); -+ memcpy(regs->RawData(), &riscv64_ucontext->uc_mcontext.__gregs[0], -+ RISCV64_REG_MAX * sizeof(uint64_t)); -+ return regs; -+} -+ -+bool RegsRiscv64::StepIfSignalHandler(uint64_t elf_offset, Elf* elf, Memory* process_memory) { -+ uint64_t data; -+ Memory* elf_memory = elf->memory(); -+ // Read from elf memory since it is usually more expensive to read from -+ // process memory. -+ if (!elf_memory->ReadFully(elf_offset, &data, sizeof(data))) { -+ return false; -+ } -+ // Look for the kernel sigreturn function. -+ // __kernel_rt_sigreturn: -+ // li a7, __NR_rt_sigreturn -+ // scall -+ -+ const uint8_t li_scall[] = {0x93, 0x08, 0xb0, 0x08, 0x73, 0x00, 0x00, 0x00}; -+ if (memcmp(&data, &li_scall, 8) != 0) { -+ return false; -+ } -+ -+ // SP + sizeof(siginfo_t) + uc_mcontext offset + PC offset. -+ if (!process_memory->ReadFully(regs_[RISCV64_REG_SP] + 0x80 + 0xb0 + 0x00, regs_.data(), -+ sizeof(uint64_t) * (RISCV64_REG_MAX))) { -+ return false; -+ } -+ return true; -+} -+ -+Regs* RegsRiscv64::Clone() { -+ return new RegsRiscv64(*this); -+} -+ -+} // namespace unwindstack -diff --git a/system/core/libunwindstack/include/unwindstack/Elf.h b/system/core/libunwindstack/include/unwindstack/Elf.h -index 472ed92..88fa0ff 100644 ---- a/system/core/libunwindstack/include/unwindstack/Elf.h -+++ b/system/core/libunwindstack/include/unwindstack/Elf.h -@@ -32,6 +32,10 @@ - #define EM_AARCH64 183 - #endif - -+#if !defined(EM_RISCV) -+#define EM_RISCV 243 -+#endif -+ - namespace unwindstack { - - // Forward declaration. -@@ -46,6 +50,7 @@ enum ArchEnum : uint8_t { - ARCH_X86_64, - ARCH_MIPS, - ARCH_MIPS64, -+ ARCH_RISCV64, - }; - - class Elf { -diff --git a/system/core/libunwindstack/include/unwindstack/MachineRiscv64.h b/system/core/libunwindstack/include/unwindstack/MachineRiscv64.h -new file mode 100644 -index 0000000..397e680 ---- /dev/null -+++ b/system/core/libunwindstack/include/unwindstack/MachineRiscv64.h -@@ -0,0 +1,59 @@ -+/* -+ * Copyright (C) 2022 The Android Open Source Project -+ * -+ * Licensed under the Apache License, Version 2.0 (the "License"); -+ * you may not use this file except in compliance with the License. -+ * You may obtain a copy of the License at -+ * -+ * http://www.apache.org/licenses/LICENSE-2.0 -+ * -+ * Unless required by applicable law or agreed to in writing, software -+ * distributed under the License is distributed on an "AS IS" BASIS, -+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -+ * See the License for the specific language governing permissions and -+ * limitations under the License. -+ */ -+ -+#pragma once -+ -+#include -+ -+namespace unwindstack { -+ -+enum Riscv64Reg : uint16_t { -+ RISCV64_REG_PC, -+ RISCV64_REG_RA, -+ RISCV64_REG_SP, -+ RISCV64_REG_GP, -+ RISCV64_REG_TP, -+ RISCV64_REG_T0, -+ RISCV64_REG_T1, -+ RISCV64_REG_T2, -+ RISCV64_REG_S0, -+ RISCV64_REG_S1, -+ RISCV64_REG_A0, -+ RISCV64_REG_A1, -+ RISCV64_REG_A2, -+ RISCV64_REG_A3, -+ RISCV64_REG_A4, -+ RISCV64_REG_A5, -+ RISCV64_REG_A6, -+ RISCV64_REG_A7, -+ RISCV64_REG_S2, -+ RISCV64_REG_S3, -+ RISCV64_REG_S4, -+ RISCV64_REG_S5, -+ RISCV64_REG_S6, -+ RISCV64_REG_S7, -+ RISCV64_REG_S8, -+ RISCV64_REG_S9, -+ RISCV64_REG_S10, -+ RISCV64_REG_S11, -+ RISCV64_REG_T3, -+ RISCV64_REG_T4, -+ RISCV64_REG_T5, -+ RISCV64_REG_T6, -+ RISCV64_REG_MAX, -+}; -+ -+} // namespace unwindstack -diff --git a/system/core/libunwindstack/include/unwindstack/RegsGetLocal.h b/system/core/libunwindstack/include/unwindstack/RegsGetLocal.h -index f0b5e3a..698eba2 100644 ---- a/system/core/libunwindstack/include/unwindstack/RegsGetLocal.h -+++ b/system/core/libunwindstack/include/unwindstack/RegsGetLocal.h -@@ -81,6 +81,49 @@ inline __attribute__((__always_inline__)) void AsmGetRegs(void* reg_data) { - : "x12", "x13", "memory"); - } - -+#elif defined(__riscv) -+ -+inline __attribute__((__always_inline__)) void AsmGetRegs(void* reg_data) { -+ asm volatile( -+ "1:\n" -+ "sd ra, 8(%[base])\n" -+ "sd sp, 16(%[base])\n" -+ "sd gp, 24(%[base])\n" -+ "sd tp, 32(%[base])\n" -+ "sd t0, 40(%[base])\n" -+ "sd t1, 48(%[base])\n" -+ "sd t2, 56(%[base])\n" -+ "sd s0, 64(%[base])\n" -+ "sd s1, 72(%[base])\n" -+ "sd a0, 80(%[base])\n" -+ "sd a1, 88(%[base])\n" -+ "sd a2, 96(%[base])\n" -+ "sd a3, 104(%[base])\n" -+ "sd a4, 112(%[base])\n" -+ "sd a5, 120(%[base])\n" -+ "sd a6, 128(%[base])\n" -+ "sd a7, 136(%[base])\n" -+ "sd s2, 144(%[base])\n" -+ "sd s3, 152(%[base])\n" -+ "sd s4, 160(%[base])\n" -+ "sd s5, 168(%[base])\n" -+ "sd s6, 176(%[base])\n" -+ "sd s7, 184(%[base])\n" -+ "sd s8, 192(%[base])\n" -+ "sd s9, 200(%[base])\n" -+ "sd s10, 208(%[base])\n" -+ "sd s11, 216(%[base])\n" -+ "sd t3, 224(%[base])\n" -+ "sd t4, 232(%[base])\n" -+ "sd t5, 240(%[base])\n" -+ "sd t6, 248(%[base])\n" -+ "la t1, 1b\n" -+ "sd t1, 0(%[base])\n" -+ : [base] "+r"(reg_data) -+ : -+ : "t1", "memory"); -+} -+ - #elif defined(__i386__) || defined(__x86_64__) || defined(__mips__) - - extern "C" void AsmGetRegs(void* regs); -diff --git a/system/core/libunwindstack/include/unwindstack/RegsRiscv64.h b/system/core/libunwindstack/include/unwindstack/RegsRiscv64.h -new file mode 100644 -index 0000000..eb09397 ---- /dev/null -+++ b/system/core/libunwindstack/include/unwindstack/RegsRiscv64.h -@@ -0,0 +1,59 @@ -+/* -+ * Copyright (C) 2022 The Android Open Source Project -+ * -+ * Licensed under the Apache License, Version 2.0 (the "License"); -+ * you may not use this file except in compliance with the License. -+ * You may obtain a copy of the License at -+ * -+ * http://www.apache.org/licenses/LICENSE-2.0 -+ * -+ * Unless required by applicable law or agreed to in writing, software -+ * distributed under the License is distributed on an "AS IS" BASIS, -+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -+ * See the License for the specific language governing permissions and -+ * limitations under the License. -+ */ -+ -+#pragma once -+ -+#include -+ -+#include -+ -+#include -+#include -+ -+namespace unwindstack { -+ -+// Forward declarations. -+class Memory; -+ -+class RegsRiscv64 : public RegsImpl { -+ public: -+ RegsRiscv64(); -+ virtual ~RegsRiscv64() = default; -+ -+ ArchEnum Arch() override final; -+ -+ uint64_t GetPcAdjustment(uint64_t rel_pc, Elf* elf) override; -+ -+ bool SetPcFromReturnAddress(Memory* process_memory) override; -+ -+ bool StepIfSignalHandler(uint64_t elf_offset, Elf* elf, Memory* process_memory) override; -+ -+ void IterateRegisters(std::function) override final; -+ -+ uint64_t pc() override; -+ uint64_t sp() override; -+ -+ void set_pc(uint64_t pc) override; -+ void set_sp(uint64_t sp) override; -+ -+ Regs* Clone() override final; -+ -+ static Regs* Read(void* data); -+ -+ static Regs* CreateFromUcontext(void* ucontext); -+}; -+ -+} // namespace unwindstack -diff --git a/system/core/libunwindstack/include/unwindstack/UcontextRiscv64.h b/system/core/libunwindstack/include/unwindstack/UcontextRiscv64.h -new file mode 100644 -index 0000000..c6c82b1 ---- /dev/null -+++ b/system/core/libunwindstack/include/unwindstack/UcontextRiscv64.h -@@ -0,0 +1,80 @@ -+/* -+ * Copyright (C) 2014 The Android Open Source Project -+ * All rights reserved. -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * * Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * * Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS -+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED -+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT -+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -+ * SUCH DAMAGE. -+ */ -+ -+#pragma once -+ -+#include -+ -+typedef uint64_t __riscv_mc_gp_state[32]; // unsigned long -+ -+struct __riscv_mc_f_ext_state { -+ uint32_t __f[32]; -+ uint32_t __fcsr; -+}; -+ -+struct __riscv_mc_d_ext_state { -+ uint64_t __f[32]; -+ uint32_t __fcsr; -+}; -+ -+struct __riscv_mc_q_ext_state { -+ uint64_t __f[64] __attribute__((__aligned__(16))); -+ uint32_t __fcsr; -+ uint32_t __reserved[3]; -+}; -+ -+union __riscv_mc_fp_state { -+ struct __riscv_mc_f_ext_state __f; -+ struct __riscv_mc_d_ext_state __d; -+ struct __riscv_mc_q_ext_state __q; -+}; -+ -+struct __riscv_stack_t { -+ uint64_t ss_sp; -+ int32_t ss_flags; -+ uint64_t ss_size; -+}; -+ -+struct riscv64_sigset_t { -+ uint64_t sig; // unsigned long -+}; -+ -+struct riscv64_mcontext_t { -+ __riscv_mc_gp_state __gregs; -+ union __riscv_mc_fp_state __fpregs; -+}; -+ -+struct riscv64_ucontext_t { -+ uint64_t uc_flags; // unsigned long -+ struct riscv64_ucontext_t* uc_link; -+ __riscv_stack_t uc_stack; -+ riscv64_sigset_t uc_sigmask; -+ /* The kernel adds extra padding here to allow sigset_t to grow. */ -+ int8_t __padding[128 - sizeof(riscv64_sigset_t)]; // char -+ riscv64_mcontext_t uc_mcontext; -+}; -diff --git a/system/core/libunwindstack/include/unwindstack/UserRiscv64.h b/system/core/libunwindstack/include/unwindstack/UserRiscv64.h -new file mode 100644 -index 0000000..1e91228 ---- /dev/null -+++ b/system/core/libunwindstack/include/unwindstack/UserRiscv64.h -@@ -0,0 +1,37 @@ -+/* -+ * Copyright (C) 2016 The Android Open Source Project -+ * All rights reserved. -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * * Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * * Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in -+ * the documentation and/or other materials provided with the -+ * distribution. -+ * -+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS -+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED -+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT -+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -+ * SUCH DAMAGE. -+ */ -+ -+#pragma once -+ -+namespace unwindstack { -+ -+struct riscv64_user_regs { -+ uint64_t regs[32]; -+}; -+ -+} // namespace unwindstack -diff --git a/system/core/libunwindstack/tools/unwind.cpp b/system/core/libunwindstack/tools/unwind.cpp -index 1812e50..ae20891 100644 ---- a/system/core/libunwindstack/tools/unwind.cpp -+++ b/system/core/libunwindstack/tools/unwind.cpp -@@ -83,6 +83,9 @@ void DoUnwind(pid_t pid) { - case unwindstack::ARCH_MIPS64: - printf("mips64"); - break; -+ case unwindstack::ARCH_RISCV64: -+ printf("riscv64"); -+ break; - default: - printf("unknown\n"); - return; -diff --git a/system/core/libunwindstack/tools/unwind_symbols.cpp b/system/core/libunwindstack/tools/unwind_symbols.cpp -index 8df2284..976db56 100644 ---- a/system/core/libunwindstack/tools/unwind_symbols.cpp -+++ b/system/core/libunwindstack/tools/unwind_symbols.cpp -@@ -77,6 +77,9 @@ int main(int argc, char** argv) { - case EM_AARCH64: - printf("ABI: arm64\n"); - break; -+ case EM_RISCV: -+ printf("ABI: riscv64\n"); -+ break; - case EM_386: - printf("ABI: x86\n"); - break; diff --git a/meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/debian/system/core/Added-missing-headers.patch b/meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/debian/system/core/Added-missing-headers.patch deleted file mode 100644 index d827d7d3c2..0000000000 --- a/meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/debian/system/core/Added-missing-headers.patch +++ /dev/null @@ -1,46 +0,0 @@ -Upstream-Status: Pending - -Description: Added missing headers causing compile errors -Author: Umang Parmar -Forwarded: not-needed - ---- a/system/core/adb/sysdeps/posix/network.cpp -+++ b/system/core/adb/sysdeps/posix/network.cpp -@@ -22,6 +22,7 @@ - #include - - #include -+#include - - #include - #include ---- a/system/core/base/file.cpp -+++ b/system/core/base/file.cpp -@@ -26,6 +26,7 @@ - #include - #include - #include -+#include - - #include - #include ---- a/system/core/libbacktrace/BacktraceMap.cpp -+++ b/system/core/libbacktrace/BacktraceMap.cpp -@@ -21,6 +21,7 @@ - #include - #include - #include -+#include - - #include - ---- a/system/core/libbacktrace/UnwindStackMap.cpp -+++ b/system/core/libbacktrace/UnwindStackMap.cpp -@@ -20,6 +20,7 @@ - - #include - #include -+#include - - #include - #include diff --git a/meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/debian/system/core/Nonnull.patch b/meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/debian/system/core/Nonnull.patch deleted file mode 100644 index 54bd52c61a..0000000000 --- a/meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/debian/system/core/Nonnull.patch +++ /dev/null @@ -1,22 +0,0 @@ -Upstream-Status: Pending - -Description: Bring Clang's _Nonnull keyword to GCC -Author: Kai-Chung Yan -Forwarded: not-needed ---- a/system/core/adb/sysdeps.h -+++ b/system/core/adb/sysdeps.h -@@ -40,11 +40,12 @@ - #include "sysdeps/network.h" - #include "sysdeps/stat.h" - -+#define _Nonnull -+#define _Nullable -+ - #ifdef _WIN32 - - // Clang-only nullability specifiers --#define _Nonnull --#define _Nullable - - #include - #include diff --git a/meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/debian/system/core/Vector-cast.patch b/meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/debian/system/core/Vector-cast.patch deleted file mode 100644 index b2881e0213..0000000000 --- a/meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/debian/system/core/Vector-cast.patch +++ /dev/null @@ -1,16 +0,0 @@ -Upstream-Status: Pending - -Description: Fix the weird error by GCC7 that fails to match the correct parent method. -Author: Kai-Chung Yan -Forwarded: not-needed ---- a/system/core/libutils/include/utils/Vector.h -+++ b/system/core/libutils/include/utils/Vector.h -@@ -256,7 +256,7 @@ - - template inline - const Vector& Vector::operator = (const Vector& rhs) const { -- VectorImpl::operator = (static_cast(rhs)); -+ VectorImpl::operator = (rhs); - return *this; - } - diff --git a/meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/debian/system/core/add-missing-headers.patch b/meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/debian/system/core/add-missing-headers.patch deleted file mode 100644 index 681d2c6553..0000000000 --- a/meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/debian/system/core/add-missing-headers.patch +++ /dev/null @@ -1,43 +0,0 @@ -Upstream-Status: Pending - -Forwarded: not-needed ---- a/system/core/fs_mgr/liblp/reader.cpp -+++ b/system/core/fs_mgr/liblp/reader.cpp -@@ -22,6 +22,7 @@ - #include - - #include -+#include - - #include - #include ---- a/system/core/fs_mgr/liblp/writer.cpp -+++ b/system/core/fs_mgr/liblp/writer.cpp -@@ -21,6 +21,7 @@ - #include - - #include -+#include - - #include - #include ---- a/system/core/liblog/logger_write.cpp -+++ b/system/core/liblog/logger_write.cpp -@@ -27,6 +27,7 @@ - #include - #endif - -+#include - #include - - #include ---- a/system/core/libziparchive/zip_archive_stream_entry.cc -+++ b/system/core/libziparchive/zip_archive_stream_entry.cc -@@ -23,6 +23,7 @@ - #include - #include - -+#include - #include - #include - diff --git a/meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/debian/system/core/android-tools-scope-write-macro-to-prevent-conflict-.patch b/meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/debian/system/core/android-tools-scope-write-macro-to-prevent-conflict-.patch deleted file mode 100644 index 61032944d8..0000000000 --- a/meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/debian/system/core/android-tools-scope-write-macro-to-prevent-conflict-.patch +++ /dev/null @@ -1,52 +0,0 @@ -From 72b53f2d5c6e1b462a288cef3d84dd302fe603d6 Mon Sep 17 00:00:00 2001 -From: Sasi Kumar Maddineni -Date: Wed, 29 Oct 2025 11:58:20 +0530 -Subject: [PATCH] android-tools: scope 'write' macro to prevent conflict with - std::basic_ostream::write - -The build fails with a compiler error due to a macro redefinition of 'write' -to '___xxx_write'. This macro substitution interferes with the standard C++ -library's definition of std::basic_ostream::write, leading to a mismatch -between function declarations and definitions in . - -Wrap the `#undef write` and `#define write ___xxx_write` directives with -`#if defined(__ANDROID__)` to ensure they are only applied when building -for -Android. - -Upstream-Status: Pending - -Signed-off-by: Sasi Kumar Maddineni ---- - system/core/adb/sysdeps.h | 4 ++++ - 1 file changed, 4 insertions(+) - -diff --git a/system/core/adb/sysdeps.h b/system/core/adb/sysdeps.h -index a4827b8a..ff51d574 100644 ---- a/system/core/adb/sysdeps.h -+++ b/system/core/adb/sysdeps.h -@@ -127,8 +127,10 @@ static __inline__ int unix_read(borrowed_fd fd, void* buf, size_t len) { - static __inline__ int unix_write(borrowed_fd fd, const void* buf, size_t len) { - return write(fd.get(), buf, len); - } -+#if defined(__ANDROID__) - #undef write - #define write ___xxx_write -+#endif - - #undef pwrite - #define pwrite ___xxx_pwrite -@@ -463,8 +465,10 @@ static __inline__ int adb_pwrite(int fd, const void* buf, size_t len, off64_t of - #endif - } - -+#if defined(__ANDROID__) - #undef write - #define write ___xxx_write -+#endif - #undef pwrite - #define pwrite ___xxx_pwrite - --- -2.34.1 - diff --git a/meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/debian/system/core/fix-attribute-issue-with-gcc.patch b/meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/debian/system/core/fix-attribute-issue-with-gcc.patch deleted file mode 100644 index 441031f536..0000000000 --- a/meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/debian/system/core/fix-attribute-issue-with-gcc.patch +++ /dev/null @@ -1,19 +0,0 @@ -Upstream-Status: Pending - -Description: remove clang-ism -Forwarded: not-needed - ---- a/system/core/base/include/android-base/logging.h -+++ b/system/core/base/include/android-base/logging.h -@@ -451,10 +451,7 @@ - // -Wno-user-defined-warnings to CPPFLAGS. - #pragma clang diagnostic push - #pragma clang diagnostic ignored "-Wgcc-compat" --#define OSTREAM_STRING_POINTER_USAGE_WARNING \ -- __attribute__((diagnose_if(true, "Unexpected logging of string pointer", "warning"))) --inline OSTREAM_STRING_POINTER_USAGE_WARNING --std::ostream& operator<<(std::ostream& stream, const std::string* string_pointer) { -+inline std::ostream& operator<<(std::ostream& stream, const std::string* string_pointer) { - return stream << static_cast(string_pointer); - } - #pragma clang diagnostic pop diff --git a/meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/debian/system/core/fix-build-on-non-x86.patch b/meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/debian/system/core/fix-build-on-non-x86.patch deleted file mode 100644 index b1caa60c4a..0000000000 --- a/meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/debian/system/core/fix-build-on-non-x86.patch +++ /dev/null @@ -1,26 +0,0 @@ -Upstream-Status: Pending - -Description: non-x86 arches do not have PAGE_SIZE -Forwarded: not-needed ---- a/system/core/base/cmsg.cpp -+++ b/system/core/base/cmsg.cpp -@@ -33,7 +33,8 @@ - const std::vector& fds) { - size_t cmsg_space = CMSG_SPACE(sizeof(int) * fds.size()); - size_t cmsg_len = CMSG_LEN(sizeof(int) * fds.size()); -- if (cmsg_space >= PAGE_SIZE) { -+ size_t pagesize = static_cast(sysconf(_SC_PAGE_SIZE)); -+ if (cmsg_space >= pagesize) { - errno = ENOMEM; - return -1; - } -@@ -75,7 +76,8 @@ - fds->clear(); - - size_t cmsg_space = CMSG_SPACE(sizeof(int) * max_fds); -- if (cmsg_space >= PAGE_SIZE) { -+ size_t pagesize = static_cast(sysconf(_SC_PAGE_SIZE)); -+ if (cmsg_space >= pagesize) { - errno = ENOMEM; - return -1; - } diff --git a/meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/debian/system/core/fix-gettid-exception-declaration.patch b/meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/debian/system/core/fix-gettid-exception-declaration.patch deleted file mode 100644 index 5f24d0b4a0..0000000000 --- a/meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/debian/system/core/fix-gettid-exception-declaration.patch +++ /dev/null @@ -1,26 +0,0 @@ -Upstream-Status: Pending - -Description: get libcutils building -Forwarded: not-needed ---- a/system/core/libcutils/include/cutils/threads.h -+++ b/system/core/libcutils/include/cutils/threads.h -@@ -33,7 +33,7 @@ - // Deprecated: use android::base::GetThreadId instead, which doesn't truncate on Mac/Windows. - // - --extern pid_t gettid(); -+extern pid_t gettid(void) __THROW; - - // - // Deprecated: use `_Thread_local` in C or `thread_local` in C++. ---- a/system/core/libcutils/threads.cpp -+++ b/system/core/libcutils/threads.cpp -@@ -33,7 +33,7 @@ - - // No definition needed for Android because we'll just pick up bionic's copy. - #ifndef __ANDROID__ --pid_t gettid() { -+pid_t gettid(void) __THROW { - #if defined(__APPLE__) - uint64_t tid; - pthread_threadid_np(NULL, &tid); diff --git a/meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/debian/system/core/fix-standard-namespace-errors.patch b/meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/debian/system/core/fix-standard-namespace-errors.patch deleted file mode 100644 index 4380308f13..0000000000 --- a/meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/debian/system/core/fix-standard-namespace-errors.patch +++ /dev/null @@ -1,24 +0,0 @@ -Upstream-Status: Pending - -Description: Add missing 'std::' scope identifiers. -Forwarded: not-needed ---- a/system/core/libunwindstack/include/unwindstack/DwarfMemory.h -+++ b/system/core/libunwindstack/include/unwindstack/DwarfMemory.h -@@ -29,7 +29,7 @@ - DwarfMemory(Memory* memory) : memory_(memory) {} - virtual ~DwarfMemory() = default; - -- bool ReadBytes(void* dst, size_t num_bytes); -+ bool ReadBytes(void* dst, std::size_t num_bytes); - - template - bool ReadSigned(uint64_t* value); -@@ -39,7 +39,7 @@ - bool ReadSLEB128(int64_t* value); - - template -- size_t GetEncodedSize(uint8_t encoding); -+ std::size_t GetEncodedSize(uint8_t encoding); - - bool AdjustEncodedValue(uint8_t encoding, uint64_t* value); - diff --git a/meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/debian/system/core/hard-code-build-number.patch b/meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/debian/system/core/hard-code-build-number.patch deleted file mode 100644 index 4d7323bd2f..0000000000 --- a/meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/debian/system/core/hard-code-build-number.patch +++ /dev/null @@ -1,46 +0,0 @@ -Upstream-Status: Pending - -Description: just hard code rather than deal with circular deps -Forwarded: not-needed ---- a/system/core/adb/adb.cpp -+++ b/system/core/adb/adb.cpp -@@ -44,8 +44,6 @@ - #include - #include - #include --#include --#include - - #include "adb_auth.h" - #include "adb_io.h" -@@ -69,7 +67,7 @@ - "Version %s-%s\n" - "Installed as %s\n", - ADB_VERSION_MAJOR, ADB_VERSION_MINOR, ADB_SERVER_VERSION, -- PLATFORM_TOOLS_VERSION, android::build::GetBuildNumber().c_str(), -+ PLATFORM_TOOLS_VERSION, "debian", - android::base::GetExecutablePath().c_str()); - } - ---- a/system/core/fastboot/fastboot.cpp -+++ b/system/core/fastboot/fastboot.cpp -@@ -59,10 +59,8 @@ - #include - #include - #include --#include - #include - #include --#include - #include - #include - -@@ -1680,7 +1678,7 @@ - setvbuf(stdout, nullptr, _IONBF, 0); - setvbuf(stderr, nullptr, _IONBF, 0); - } else if (name == "version") { -- fprintf(stdout, "fastboot version %s-%s\n", PLATFORM_TOOLS_VERSION, android::build::GetBuildNumber().c_str()); -+ fprintf(stdout, "fastboot version %s-%s\n", PLATFORM_TOOLS_VERSION, "debian"); - fprintf(stdout, "Installed as %s\n", android::base::GetExecutablePath().c_str()); - return 0; - #if !defined(_WIN32) diff --git a/meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/debian/system/core/libusb-header-path.patch b/meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/debian/system/core/libusb-header-path.patch deleted file mode 100644 index 122bd70e7d..0000000000 --- a/meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/debian/system/core/libusb-header-path.patch +++ /dev/null @@ -1,18 +0,0 @@ -Upstream-Status: Pending - -Description: libusb.h comes from different location -Author: Umang Parmar -Forwarded: not-needed -Last-Update: 2018-05-26 - ---- a/system/core/adb/client/usb_libusb.cpp -+++ b/system/core/adb/client/usb_libusb.cpp -@@ -30,7 +30,7 @@ - #include - #include - --#include -+#include - - #include - #include diff --git a/meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/debian/system/core/libziparchive-fix-missing-fixed-width-integer-types-.patch b/meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/debian/system/core/libziparchive-fix-missing-fixed-width-integer-types-.patch deleted file mode 100644 index 0b5087f283..0000000000 --- a/meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/debian/system/core/libziparchive-fix-missing-fixed-width-integer-types-.patch +++ /dev/null @@ -1,38 +0,0 @@ -From f6874a2f7de30b6eeefb2d509b895c58b93da8f7 Mon Sep 17 00:00:00 2001 -From: Sasi Kumar Maddineni -Date: Wed, 29 Oct 2025 09:38:17 +0530 -Subject: [PATCH] libziparchive: fix missing fixed-width integer types in - zip_writer.h - -Compilation fails due to undefined types 'uint16_t' and 'uint32_t' in -zip_writer.h. These types are used in struct members but are not recognized -because the required header is not included. This results in -errors such as: - error: 'uint16_t' does not name a type - error: 'uint32_t' does not name a type - -Added '#include ' to zip_writer.h to ensure fixed-width integer -types are properly defined. - -Upstream-Status: Pending - -Signed-off-by: Sasi Kumar Maddineni ---- - system/core/libziparchive/include/ziparchive/zip_writer.h | 1 + - 1 file changed, 1 insertion(+) - -diff --git a/system/core/libziparchive/include/ziparchive/zip_writer.h b/system/core/libziparchive/include/ziparchive/zip_writer.h -index d68683df..7a05e349 100644 ---- a/system/core/libziparchive/include/ziparchive/zip_writer.h -+++ b/system/core/libziparchive/include/ziparchive/zip_writer.h -@@ -18,6 +18,7 @@ - - #include - #include -+#include - - #include - #include --- -2.34.1 - diff --git a/meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/debian/system/core/move-log-file-to-proper-dir.patch b/meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/debian/system/core/move-log-file-to-proper-dir.patch deleted file mode 100644 index e8494ab433..0000000000 --- a/meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/debian/system/core/move-log-file-to-proper-dir.patch +++ /dev/null @@ -1,20 +0,0 @@ -Upstream-Status: Pending - -Description: Update log file directory. -Author: Umang Parmar -Last Updated: 2018-05-17 - ---- a/system/core/adb/adb_utils.cpp -+++ b/system/core/adb/adb_utils.cpp -@@ -339,6 +339,11 @@ - - return temp_path_utf8 + log_name; - #else -+ std::string log_dir = android::base::StringPrintf("/run/user/%u/adb.log", getuid()); -+ struct stat st = {0}; -+ if (stat(log_dir.c_str(), &st) == 0) { -+ return log_dir; -+ } - const char* tmp_dir = getenv("TMPDIR"); - if (tmp_dir == nullptr) tmp_dir = "/tmp"; - return android::base::StringPrintf("%s/adb.%u.log", tmp_dir, getuid()); diff --git a/meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/debian/system/core/simg_dump-python3.patch b/meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/debian/system/core/simg_dump-python3.patch deleted file mode 100644 index 6664dc2aa5..0000000000 --- a/meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/debian/system/core/simg_dump-python3.patch +++ /dev/null @@ -1,64 +0,0 @@ -Description: Port simg_dump to Python 3. -Author: Antonio Russo -Forwarded: not-needed -Last-Update: 2019-01-05 -Origin: https://bugs.debian.org/945646 - ---- -Upstream-Status: Pending - -Index: android-platform-tools/system/core/libsparse/simg_dump.py -=================================================================== ---- android-platform-tools.orig/system/core/libsparse/simg_dump.py -+++ android-platform-tools/system/core/libsparse/simg_dump.py -@@ -1,4 +1,4 @@ --#! /usr/bin/env python -+#! /usr/bin/env python3 - - # Copyright (C) 2012 The Android Open Source Project - # -@@ -14,7 +14,7 @@ - # See the License for the specific language governing permissions and - # limitations under the License. - --from __future__ import print_function -+ - import csv - import getopt - import hashlib -@@ -47,7 +47,7 @@ def main(): - opts, args = getopt.getopt(sys.argv[1:], - "vsc:", - ["verbose", "showhash", "csvfile"]) -- except getopt.GetoptError, e: -+ except getopt.GetoptError as e: - print(e) - usage(me) - for o, a in opts: -@@ -66,7 +66,7 @@ def main(): - usage(me) - - if csvfilename: -- csvfile = open(csvfilename, "wb") -+ csvfile = open(csvfilename, "w", newline='') - csvwriter = csv.writer(csvfile) - - output = verbose or csvfilename or showhash -@@ -121,7 +121,7 @@ def main(): - "output offset", "output blocks", "type", "hash"]) - - offset = 0 -- for i in xrange(1, total_chunks + 1): -+ for i in range(1, total_chunks + 1): - header_bin = FH.read(12) - header = struct.unpack("<2H2I", header_bin) - chunk_type = header[0] -@@ -160,7 +160,7 @@ def main(): - if showhash: - h = hashlib.sha1() - data = fill_bin * (blk_sz / 4); -- for block in xrange(chunk_sz): -+ for block in range(chunk_sz): - h.update(data) - curhash = h.hexdigest() - elif chunk_type == 0xCAC3: diff --git a/meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/debian/system/core/stdatomic.patch b/meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/debian/system/core/stdatomic.patch deleted file mode 100644 index e11f3cc783..0000000000 --- a/meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/debian/system/core/stdatomic.patch +++ /dev/null @@ -1,66 +0,0 @@ -Upstream-Status: Pending - -Description: Fix incompatibility between and - This 2 headers combined will cause errors for both GCC and Clang. This patch - makes sure only one of them is present at any time. -Bug: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60932 -Bug: https://reviews.llvm.org/D45470 ---- a/system/core/libcutils/include/cutils/trace.h -+++ b/system/core/libcutils/include/cutils/trace.h -@@ -18,7 +18,14 @@ - #define _LIBS_CUTILS_TRACE_H - - #include -+#ifdef __cplusplus -+#include -+using std::atomic_bool; -+using std::atomic_load_explicit; -+using std::memory_order_acquire; -+#else - #include -+#endif - #include - #include - #include ---- a/system/core/libcutils/include/cutils/atomic.h -+++ b/system/core/libcutils/include/cutils/atomic.h -@@ -19,7 +19,23 @@ - - #include - #include -+#ifdef __cplusplus -+#include -+using std::atomic_compare_exchange_strong_explicit; -+using std::atomic_fetch_add_explicit; -+using std::atomic_fetch_or_explicit; -+using std::atomic_fetch_sub_explicit; -+using std::atomic_int_least32_t; -+using std::atomic_load_explicit; -+using std::atomic_store_explicit; -+using std::atomic_thread_fence; -+using std::memory_order::memory_order_acquire; -+using std::memory_order::memory_order_relaxed; -+using std::memory_order::memory_order_release; -+using std::memory_order::memory_order_seq_cst; -+#else - #include -+#endif - - #ifndef ANDROID_ATOMIC_INLINE - #define ANDROID_ATOMIC_INLINE static inline ---- a/system/core/liblog/logger.h -+++ b/system/core/liblog/logger.h -@@ -16,7 +16,13 @@ - - #pragma once - -+#ifdef __cplusplus -+#include -+using std::atomic_int; -+using std::atomic_uintptr_t; -+#else - #include -+#endif - #include - - #include diff --git a/meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/debian/system/core/stub-out-fastdeploy.patch b/meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/debian/system/core/stub-out-fastdeploy.patch deleted file mode 100644 index d86ef230f7..0000000000 --- a/meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/debian/system/core/stub-out-fastdeploy.patch +++ /dev/null @@ -1,95 +0,0 @@ -Upstream-Status: Pending - -Description: Defer packaging fastdeploy with adb for 29.x.x tags. -Forwarded: not-needed ---- a/system/core/adb/client/commandline.cpp -+++ b/system/core/adb/client/commandline.cpp -@@ -59,7 +59,6 @@ - #include "bugreport.h" - #include "client/file_sync_client.h" - #include "commandline.h" --#include "fastdeploy.h" - #include "services.h" - #include "shell_protocol.h" - #include "sysdeps/chrono.h" ---- a/system/core/adb/client/adb_install.cpp -+++ b/system/core/adb/client/adb_install.cpp -@@ -35,7 +35,6 @@ - #include "adb_utils.h" - #include "client/file_sync_client.h" - #include "commandline.h" --#include "fastdeploy.h" - - static constexpr int kFastDeployMinApi = 24; - -@@ -167,14 +166,6 @@ - } - - if (use_fastdeploy) { -- auto metadata = extract_metadata(file); -- if (metadata.has_value()) { -- // pass all but 1st (command) and last (apk path) parameters through to pm for -- // session creation -- std::vector pm_args{argv + 1, argv + argc - 1}; -- auto patchFd = install_patch(pm_args.size(), pm_args.data()); -- return stream_patch(file, std::move(metadata.value()), std::move(patchFd)); -- } - } - - struct stat sb; -@@ -267,16 +258,6 @@ - argv[last_apk] = apk_dest.c_str(); /* destination name, not source location */ - - if (use_fastdeploy) { -- auto metadata = extract_metadata(apk_file[0]); -- if (metadata.has_value()) { -- auto patchFd = apply_patch_on_device(apk_dest.c_str()); -- int status = stream_patch(apk_file[0], std::move(metadata.value()), std::move(patchFd)); -- -- result = pm_command(argc, argv); -- delete_device_file(apk_dest); -- -- return status; -- } - } - - if (do_sync_push(apk_file, apk_dest.c_str(), false)) { -@@ -292,7 +273,6 @@ - InstallMode installMode = INSTALL_DEFAULT; - bool use_fastdeploy = false; - bool is_reinstall = false; -- FastDeploy_AgentUpdateStrategy agent_update_strategy = FastDeploy_AgentUpdateDifferentVersion; - - for (int i = 1; i < argc; i++) { - if (!strcmp(argv[i], "--streaming")) { -@@ -313,13 +293,10 @@ - use_fastdeploy = false; - } else if (!strcmp(argv[i], "--force-agent")) { - processedArgIndicies.push_back(i); -- agent_update_strategy = FastDeploy_AgentUpdateAlways; - } else if (!strcmp(argv[i], "--date-check-agent")) { - processedArgIndicies.push_back(i); -- agent_update_strategy = FastDeploy_AgentUpdateNewerTimeStamp; - } else if (!strcmp(argv[i], "--version-check-agent")) { - processedArgIndicies.push_back(i); -- agent_update_strategy = FastDeploy_AgentUpdateDifferentVersion; - } - } - -@@ -331,13 +308,11 @@ - error_exit("Attempting to use streaming install on unsupported device"); - } - -- if (use_fastdeploy && get_device_api_level() < kFastDeployMinApi) { -- printf("Fast Deploy is only compatible with devices of API version %d or higher, " -- "ignoring.\n", -- kFastDeployMinApi); -+ if (use_fastdeploy) { -+ printf("Fast Deploy is unavailable in this build of adb, " -+ "ignoring.\n"); - use_fastdeploy = false; - } -- fastdeploy_set_agent_update_strategy(agent_update_strategy); - - std::vector passthrough_argv; - for (int i = 0; i < argc; i++) { diff --git a/meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/debian/system/core/throw-exception-on-unknown-os.patch b/meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/debian/system/core/throw-exception-on-unknown-os.patch deleted file mode 100644 index 70e732131f..0000000000 --- a/meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/debian/system/core/throw-exception-on-unknown-os.patch +++ /dev/null @@ -1,18 +0,0 @@ -Upstream-Status: Pending - -Description: Turn #error into exceptions - So the library can be built on non-Linux platforms too, although can't - guarauntee its functionality regarding that piece of code. -Forwarded: not-needed ---- a/system/core/base/file.cpp -+++ b/system/core/base/file.cpp -@@ -422,7 +422,8 @@ - path[PATH_MAX - 1] = 0; - return path; - #else --#error unknown OS -+#include -+ throw std::runtime_error(std::string("Unknown OS!")); - #endif - } - diff --git a/meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/debian/throw-exception-on-unknown-os.patch b/meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/debian/throw-exception-on-unknown-os.patch deleted file mode 100644 index 70e732131f..0000000000 --- a/meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/debian/throw-exception-on-unknown-os.patch +++ /dev/null @@ -1,18 +0,0 @@ -Upstream-Status: Pending - -Description: Turn #error into exceptions - So the library can be built on non-Linux platforms too, although can't - guarauntee its functionality regarding that piece of code. -Forwarded: not-needed ---- a/system/core/base/file.cpp -+++ b/system/core/base/file.cpp -@@ -422,7 +422,8 @@ - path[PATH_MAX - 1] = 0; - return path; - #else --#error unknown OS -+#include -+ throw std::runtime_error(std::string("Unknown OS!")); - #endif - } - diff --git a/meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/remount b/meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/remount deleted file mode 100644 index 751c3501ef..0000000000 --- a/meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/remount +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -mount -o remount,rw / diff --git a/meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/rules_yocto.mk b/meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/rules_yocto.mk deleted file mode 100644 index 2c808d3c1e..0000000000 --- a/meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/rules_yocto.mk +++ /dev/null @@ -1 +0,0 @@ -CPPFLAGS += -fPIC diff --git a/meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools_29.0.6.r14.bb b/meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools_29.0.6.r14.bb deleted file mode 100644 index 3d4e95b496..0000000000 --- a/meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools_29.0.6.r14.bb +++ /dev/null @@ -1,193 +0,0 @@ -DESCRIPTION = "Various utilities from Android" -SECTION = "console/utils" -LICENSE = "Apache-2.0 & GPL-2.0-only & BSD-2-Clause & BSD-3-Clause" -LIC_FILES_CHKSUM = " \ - file://${COMMON_LICENSE_DIR}/Apache-2.0;md5=89aea4e17d99a7cacdbeed46a0096b10 \ - file://${COMMON_LICENSE_DIR}/GPL-2.0-only;md5=801f80980d171dd6425610833a22dbe6 \ - file://${COMMON_LICENSE_DIR}/BSD-2-Clause;md5=cb641bc04cda31daea161b1bc15da69f \ - file://${COMMON_LICENSE_DIR}/BSD-3-Clause;md5=550794465ba0ec5312d6919e203a55f9 \ -" -DEPENDS = "libbsd libpcre zlib libcap libusb squashfs-tools 7zip libselinux googletest" - -SRCREV_core = "abfd66fafcbb691d7860df059f1df1c9b1ef29da" - -SRC_URI = " \ - git://salsa.debian.org/android-tools-team/android-platform-tools;name=core;protocol=https;branch=master \ -" - -# Patches copied from android-platform-tools/debian/patches -# and applied in the order defined by the file debian/patches/series -SRC_URI += " \ - file://debian/external/libunwind/user_pt_regs.patch \ - file://debian/external/libunwind/legacy_built-in_sync_functions.patch \ - file://debian/external/libunwind/20150704-CVE-2015-3239_dwarf_i.h.patch \ - file://debian/external/libunwind/libunwind-guard-unreachable-macro-to-avoid-redefinit.patch \ - file://debian/external/libunwind/libunwind-fix-strchr-conformance-to-ISO-C23.patch \ - \ - file://debian/system/core/move-log-file-to-proper-dir.patch \ - file://debian/system/core/Added-missing-headers.patch \ - file://debian/system/core/libusb-header-path.patch \ - file://debian/system/core/stdatomic.patch \ - file://debian/system/core/Nonnull.patch \ - file://debian/system/core/Vector-cast.patch \ - file://debian/system/core/throw-exception-on-unknown-os.patch \ - file://debian/system/core/simg_dump-python3.patch \ - file://debian/system/core/fix-attribute-issue-with-gcc.patch \ - file://debian/system/core/fix-gettid-exception-declaration.patch \ - file://debian/system/core/fix-build-on-non-x86.patch \ - file://debian/system/core/add-missing-headers.patch \ - file://debian/system/core/hard-code-build-number.patch \ - file://debian/system/core/stub-out-fastdeploy.patch \ - file://debian/system/core/fix-standard-namespace-errors.patch \ - file://debian/system/core/Add-riscv64-support.patch \ - file://debian/system/core/android-tools-scope-write-macro-to-prevent-conflict-.patch \ - file://debian/system/core/libziparchive-fix-missing-fixed-width-integer-types-.patch \ - \ -" - -# patches which don't come from debian -SRC_URI += " \ - file://rules_yocto.mk;subdir=${BB_GIT_DEFAULT_DESTSUFFIX} \ - file://android-tools-adbd.service \ - file://adbd.mk;subdir=${BB_GIT_DEFAULT_DESTSUFFIX}/debian/system/core \ - file://remount \ - file://0001-Fixes-for-yocto-build.patch \ - file://0002-android-tools-modifications-to-make-it-build-in-yoct.patch \ - file://0003-Update-usage-of-usbdevfs_urb-to-match-new-kernel-UAP.patch \ - file://0004-adb-Fix-build-on-big-endian-systems.patch \ - file://0005-adb-Allow-adbd-to-be-run-as-root.patch \ - file://0001-liblp-fix-building-with-GCC-14.patch \ -" - -B = "${WORKDIR}/${BPN}" - -# http://errors.yoctoproject.org/Errors/Details/1debian881/ -ARM_INSTRUCTION_SET:armv4 = "arm" -ARM_INSTRUCTION_SET:armv5 = "arm" - -COMPATIBLE_HOST:powerpc = "(null)" -COMPATIBLE_HOST:powerpc64 = "(null)" -COMPATIBLE_HOST:powerpc64le = "(null)" - -inherit systemd - -SYSTEMD_PACKAGES = "${PN}-adbd" -SYSTEMD_SERVICE:${PN}-adbd = "android-tools-adbd.service" - -# Find libbsd headers during native builds -CC:append:class-native = " -I${STAGING_INCDIR}" -CC:append:class-nativesdk = " -I${STAGING_INCDIR}" - -PREREQUISITE_core = "liblog libbase libsparse liblog libcutils" -TOOLS_TO_BUILD = "libcrypto_utils libadb libziparchive fastboot adb img2simg simg2img libbacktrace" -TOOLS_TO_BUILD:append:class-target = " adbd" - -do_compile() { - - case "${HOST_ARCH}" in - arm) - export android_arch=linux-arm - cpu=arm - deb_host_arch=arm - ;; - aarch64) - export android_arch=linux-arm64 - cpu=arm64 - deb_host_arch=arm64 - ;; - riscv64) - export android_arch=linux-riscv64 - ;; - mips|mipsel) - export android_arch=linux-mips - cpu=mips - deb_host_arch=mips - ;; - mips64|mips64el) - export android_arch=linux-mips64 - cpu=mips64 - deb_host_arch=mips64 - ;; - powerpc|powerpc64) - export android_arch=linux-ppc - ;; - i586|i686|x86_64) - export android_arch=linux-x86 - cpu=x86_64 - deb_host_arch=amd64 - ;; - esac - - export SRCDIR=${S} - - oe_runmake -f ${S}/debian/external/boringssl/libcrypto.mk -C ${S} - oe_runmake -f ${S}/debian/external/libunwind/libunwind.mk -C ${S} CPU=${cpu} - - for tool in ${PREREQUISITE_core}; do - oe_runmake -f ${S}/debian/system/core/${tool}.mk -C ${S} - done - - for i in `find ${S}/debian/system/extras/ -name "*.mk"`; do - oe_runmake -f $i -C ${S} - done - - for tool in ${TOOLS_TO_BUILD}; do - if [ "$tool" = "libbacktrace" ]; then - oe_runmake -f ${S}/debian/system/core/${tool}.mk -C ${S} DEB_HOST_ARCH=${deb_host_arch} - else - oe_runmake -f ${S}/debian/system/core/${tool}.mk -C ${S} - fi - done - -} - -do_install() { - install -d ${D}${base_sbindir} - install -m 0755 ${UNPACKDIR}/remount -D ${D}${base_sbindir}/remount - - for tool in img2simg simg2img fastboot adbd; do - if echo ${TOOLS_TO_BUILD} | grep -q "$tool" ; then - install -D -p -m0755 ${S}/debian/out/system/core/$tool ${D}${bindir}/$tool - fi - done - - # grep adb also matches adbd, so handle adb separately from other tools - if echo ${TOOLS_TO_BUILD} | grep -q "adb " ; then - install -d ${D}${bindir} - install -m0755 ${S}/debian/out/system/core/adb ${D}${bindir} - fi - - # Outside the if statement to avoid errors during do_package - install -D -p -m0644 ${UNPACKDIR}/android-tools-adbd.service \ - ${D}${systemd_unitdir}/system/android-tools-adbd.service - - install -d ${D}${libdir}/android/ - install -m0755 ${S}/debian/out/system/core/*.so.* ${D}${libdir}/android/ - if echo ${TOOLS_TO_BUILD} | grep -q "mkbootimg" ; then - install -d ${D}${bindir} - install -m0755 ${B}/mkbootimg/mkbootimg ${D}${bindir} - fi -} - -PACKAGES =+ "${PN}-fstools ${PN}-adbd" - -RDEPENDS:${BPN} = "${BPN}-conf 7zip" - -FILES:${PN}-adbd = "\ - ${bindir}/adbd \ - ${systemd_unitdir}/system/android-tools-adbd.service \ -" - -FILES:${PN}-fstools = "\ - ${bindir}/ext2simg \ - ${bindir}/ext4fixup \ - ${bindir}/img2simg \ - ${bindir}/make_ext4fs \ - ${bindir}/simg2img \ - ${bindir}/simg2simg \ - ${bindir}/simg_dump \ - ${bindir}/mkuserimg \ -" -FILES:${PN} += "${libdir}/android ${libdir}/android/*" - -BBCLASSEXTEND = "native" diff --git a/meta-oe/recipes-devtools/android-tools/android-tools-conf/android-gadget-setup b/meta-oe/recipes-devtools/android-tools/android-tools-conf/android-gadget-setup new file mode 100644 index 0000000000..26cf30eddd --- /dev/null +++ b/meta-oe/recipes-devtools/android-tools/android-tools-conf/android-gadget-setup @@ -0,0 +1,37 @@ +#!/bin/sh + +[ ! -e /dev/pts ] && mkdir -p /dev/pts +[ ! -e /dev/pts/0 ] && mount devpts /dev/pts -t devpts + +# TODO enable the lines below once we have support for getprop +# retrieve the product info from Android +# manufacturer=$(getprop ro.product.manufacturer Android) +# model=$(getprop ro.product.model Android) +# serial=$(getprop ro.serialno 0123456789ABCDEF) + +#below are now needed in order to use FunctionFS for ADB, tested to work with 3.4+ kernels +if grep -q functionfs /proc/filesystems; then + mkdir -p /dev/usb-ffs/adb + mount -t functionfs adb /dev/usb-ffs/adb + #android-gadget-setup doesn't provide below 2 and without them it won't work, so we provide them here. + echo adb > /sys/class/android_usb/android0/f_ffs/aliases + echo ffs > /sys/class/android_usb/android0/functions +fi + +manufacturer="$(cat /system/build.prop | grep -o 'ro.product.manufacturer=.*' | cut -d'=' -f 2)" +model="$(cat /system/build.prop | grep -o 'ro.product.model=.*' | cut -d'=' -f 2)" +# get the device serial number from /proc/cmdline directly(since we have no getprop on +# GNU/Linux) +serial="$(cat /proc/cmdline | sed 's/.*androidboot.serialno=//' | sed 's/ .*//')" + +echo $serial > /sys/class/android_usb/android0/iSerial +echo $manufacturer > /sys/class/android_usb/android0/iManufacturer +echo $model > /sys/class/android_usb/android0/iProduct + +echo "0" > /sys/class/android_usb/android0/enable +echo "18d1" > /sys/class/android_usb/android0/idVendor +echo "D002" > /sys/class/android_usb/android0/idProduct +echo "adb" > /sys/class/android_usb/android0/functions +echo "1" > /sys/class/android_usb/android0/enable + +sleep 4 diff --git a/meta-oe/recipes-devtools/android-tools/android-tools-conf_1.0.bb b/meta-oe/recipes-devtools/android-tools/android-tools-conf_1.0.bb new file mode 100644 index 0000000000..7bbac1db75 --- /dev/null +++ b/meta-oe/recipes-devtools/android-tools/android-tools-conf_1.0.bb @@ -0,0 +1,20 @@ +DESCRIPTION = "Different utilities from Android - corresponding configuration files" +SECTION = "console/utils" +LICENSE = "MIT" +LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302" + +SRC_URI = "file://android-gadget-setup" + +S = "${UNPACKDIR}" + +do_install() { + install -d ${D}${bindir} + install -m 0755 ${UNPACKDIR}/android-gadget-setup ${D}${bindir} +} + +python () { + pn = d.getVar('PN') + profprov = d.getVar("PREFERRED_PROVIDER_" + pn) + if profprov and pn != profprov: + raise bb.parse.SkipRecipe("PREFERRED_PROVIDER_%s set to %s, not %s" % (pn, profprov, pn)) +} diff --git a/meta-oe/recipes-devtools/android-tools/android-tools/0001-Fixes-for-yocto-build.patch b/meta-oe/recipes-devtools/android-tools/android-tools/0001-Fixes-for-yocto-build.patch new file mode 100644 index 0000000000..1d18d47ec3 --- /dev/null +++ b/meta-oe/recipes-devtools/android-tools/android-tools/0001-Fixes-for-yocto-build.patch @@ -0,0 +1,164 @@ +From 5de85f8273c7284aa93e35c40f025d4d43d42df9 Mon Sep 17 00:00:00 2001 +From: Etienne Cordonnier +Date: Thu, 16 Mar 2023 18:59:35 +0100 +Subject: [PATCH] Fixes for yocto build + +Signed-off-by: JJ Robertson +[rebased on version 29] +Signed-off-by: Etienne Cordonnier + +--- +Upstream-Status: Pending + + system/core/adb/daemon/file_sync_service.cpp | 4 ++-- + system/core/adb/daemon/framebuffer_service.h | 2 -- + system/core/adb/daemon/main.cpp | 5 +++-- + system/core/adb/daemon/restart_service.h | 2 -- + system/core/adb/daemon/services.cpp | 6 ++---- + system/core/adb/daemon/shell_service.cpp | 5 ++++- + system/core/adb/types.h | 1 + + 7 files changed, 12 insertions(+), 13 deletions(-) + +diff --git a/system/core/adb/daemon/file_sync_service.cpp b/system/core/adb/daemon/file_sync_service.cpp +index d6af7087..92e7087a 100644 +--- a/system/core/adb/daemon/file_sync_service.cpp ++++ b/system/core/adb/daemon/file_sync_service.cpp +@@ -111,7 +111,7 @@ static bool secure_mkdirs(const std::string& path) { + partial_path += path_component; + + if (should_use_fs_config(partial_path)) { +- fs_config(partial_path.c_str(), 1, nullptr, &uid, &gid, &mode, &capabilities); ++ // fs_config(partial_path.c_str(), 1, nullptr, &uid, &gid, &mode, &capabilities); + } + if (adb_mkdir(partial_path.c_str(), mode) == -1) { + if (errno != EEXIST) { +@@ -469,7 +469,7 @@ static bool do_send(int s, const std::string& spec, std::vector& buffer) { + uint64_t capabilities = 0; + if (should_use_fs_config(path)) { + unsigned int broken_api_hack = mode; +- fs_config(path.c_str(), 0, nullptr, &uid, &gid, &broken_api_hack, &capabilities); ++ // fs_config(path.c_str(), 0, nullptr, &uid, &gid, &broken_api_hack, &capabilities); + mode = broken_api_hack; + } + +diff --git a/system/core/adb/daemon/framebuffer_service.h b/system/core/adb/daemon/framebuffer_service.h +index bab44be3..264da597 100644 +--- a/system/core/adb/daemon/framebuffer_service.h ++++ b/system/core/adb/daemon/framebuffer_service.h +@@ -18,6 +18,4 @@ + + #include "adb_unique_fd.h" + +-#if defined(__ANDROID__) + void framebuffer_service(unique_fd fd); +-#endif +diff --git a/system/core/adb/daemon/main.cpp b/system/core/adb/daemon/main.cpp +index 3322574c..e807d13d 100644 +--- a/system/core/adb/daemon/main.cpp ++++ b/system/core/adb/daemon/main.cpp +@@ -208,6 +208,9 @@ int adbd_main(int server_port) { + umask(0); + + signal(SIGPIPE, SIG_IGN); ++ signal(SIGINT, SIG_DFL); ++ signal(SIGQUIT, SIG_DFL); ++ + + #if defined(__BIONIC__) + auto fdsan_level = android_fdsan_get_error_level(); +@@ -254,13 +257,11 @@ int adbd_main(int server_port) { + + bool is_usb = false; + +-#if defined(__ANDROID__) + if (access(USB_FFS_ADB_EP0, F_OK) == 0) { + // Listen on USB. + usb_init(); + is_usb = true; + } +-#endif + + // If one of these properties is set, also listen on that port. + // If one of the properties isn't set and we couldn't listen on usb, listen +diff --git a/system/core/adb/daemon/restart_service.h b/system/core/adb/daemon/restart_service.h +index 19840bd5..7a97614b 100644 +--- a/system/core/adb/daemon/restart_service.h ++++ b/system/core/adb/daemon/restart_service.h +@@ -18,9 +18,7 @@ + + #include "adb_unique_fd.h" + +-#if defined(__ANDROID__) + void restart_root_service(unique_fd fd); + void restart_unroot_service(unique_fd fd); + void restart_tcp_service(unique_fd fd, int port); + void restart_usb_service(unique_fd fd); +-#endif +diff --git a/system/core/adb/daemon/services.cpp b/system/core/adb/daemon/services.cpp +index 4ec90d27..d8541c23 100644 +--- a/system/core/adb/daemon/services.cpp ++++ b/system/core/adb/daemon/services.cpp +@@ -156,7 +156,7 @@ static void spin_service(unique_fd fd) { + } + #endif + // Fall through +- std::string cmd = "/system/bin/reboot "; ++ std::string cmd = "/sbin/reboot "; + cmd += name; + return StartSubprocess(cmd, nullptr, SubprocessType::kRaw, SubprocessProtocol::kNone); + } +@@ -265,11 +265,10 @@ unique_fd daemon_service_to_fd(std::string_view name, atransport* transport) { + } + #endif + +-#if defined(__ANDROID__) + if (name.starts_with("framebuffer:")) { + return create_service_thread("fb", framebuffer_service); + } else if (android::base::ConsumePrefix(&name, "remount:")) { +- std::string cmd = "/system/bin/remount "; ++ std::string cmd = "/sbin/remount "; + cmd += name; + return StartSubprocess(cmd, nullptr, SubprocessType::kRaw, SubprocessProtocol::kNone); + } else if (android::base::ConsumePrefix(&name, "reboot:")) { +@@ -303,7 +302,6 @@ unique_fd daemon_service_to_fd(std::string_view name, atransport* transport) { + } else if (name.starts_with("usb:")) { + return create_service_thread("usb", restart_usb_service); + } +-#endif + + if (android::base::ConsumePrefix(&name, "dev:")) { + return unique_fd{unix_open(name, O_RDWR | O_CLOEXEC)}; +diff --git a/system/core/adb/daemon/shell_service.cpp b/system/core/adb/daemon/shell_service.cpp +index f62032d0..ebcfe18d 100644 +--- a/system/core/adb/daemon/shell_service.cpp ++++ b/system/core/adb/daemon/shell_service.cpp +@@ -273,13 +273,16 @@ bool Subprocess::ForkAndExec(std::string* error) { + env["HOSTNAME"] = GetHostName(); + env["LOGNAME"] = pw->pw_name; + env["SHELL"] = pw->pw_shell; +- env["TMPDIR"] = "/data/local/tmp"; + env["USER"] = pw->pw_name; + } + + if (!terminal_type_.empty()) { + env["TERM"] = terminal_type_; + } ++ if (env.find("PS1") == env.end()) { ++ env["PS1"] = "\\h:\\w\\$ "; ++ } ++ + + std::vector joined_env; + for (const auto& it : env) { +diff --git a/system/core/adb/types.h b/system/core/adb/types.h +index c619fffc..f8e0f521 100644 +--- a/system/core/adb/types.h ++++ b/system/core/adb/types.h +@@ -22,6 +22,7 @@ + #include + #include + #include ++#include + + #include + diff --git a/meta-oe/recipes-devtools/android-tools/android-tools/0001-liblp-fix-building-with-GCC-14.patch b/meta-oe/recipes-devtools/android-tools/android-tools/0001-liblp-fix-building-with-GCC-14.patch new file mode 100644 index 0000000000..ccd289c81b --- /dev/null +++ b/meta-oe/recipes-devtools/android-tools/android-tools/0001-liblp-fix-building-with-GCC-14.patch @@ -0,0 +1,26 @@ +From 9f4d839847666019cadf57aa34fd366801c11a44 Mon Sep 17 00:00:00 2001 +From: Dmitry Baryshkov +Date: Fri, 24 May 2024 14:13:35 +0300 +Subject: [PATCH] liblp: fix building with GCC 14 + +Upstream-Status: Pending +Signed-off-by: Dmitry Baryshkov +--- + system/core/fs_mgr/liblp/utility.cpp | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/system/core/fs_mgr/liblp/utility.cpp b/system/core/fs_mgr/liblp/utility.cpp +index 48c5c8318d99..0aa8023aa87d 100644 +--- a/system/core/fs_mgr/liblp/utility.cpp ++++ b/system/core/fs_mgr/liblp/utility.cpp +@@ -24,6 +24,7 @@ + #include + #endif + ++#include + #include + #include + #include +-- +2.39.2 + diff --git a/meta-oe/recipes-devtools/android-tools/android-tools/0002-android-tools-modifications-to-make-it-build-in-yoct.patch b/meta-oe/recipes-devtools/android-tools/android-tools/0002-android-tools-modifications-to-make-it-build-in-yoct.patch new file mode 100644 index 0000000000..a35428b5b4 --- /dev/null +++ b/meta-oe/recipes-devtools/android-tools/android-tools/0002-android-tools-modifications-to-make-it-build-in-yoct.patch @@ -0,0 +1,453 @@ +From 194513bababa9707ec54bc7119613a0d5eca9f79 Mon Sep 17 00:00:00 2001 +From: Etienne Cordonnier +Date: Fri, 17 Mar 2023 10:33:11 +0100 +Subject: [PATCH] android-tools: modifications to make it build in yocto + +- Fix relocation errors on aarch64, e.g.: +"relocation R_AARCH64_ADR_PREL_PG_HI21 against symbol `_ZTV19SparseFileBufSource' which may bind externally can not be used when making a shared object; recompile with -fPIC" + +- use ln -f to avoid error "File exists" on incremental builds + +- fix missing headers + +Signed-off-by: Etienne Cordonnier + +- fix warning: library search path "/usr/lib/p7zip" is unsafe for cross-compilation + +- fix error: include location "/usr/include/android" is unsafe for cross-compilation + +Upstream-Status: Pending +Signed-off-by: Hongxu Jia +--- + debian/development/etc1tool.mk | 1 - + debian/external/boringssl/libcrypto.mk | 1 + + debian/libnativehelper/libnativehelper.mk | 1 - + debian/system/core/adb.mk | 1 - + debian/system/core/append2simg.mk | 2 +- + debian/system/core/fastboot.mk | 3 +-- + debian/system/core/img2simg.mk | 2 +- + debian/system/core/libbacktrace.mk | 10 ++++------ + debian/system/core/libbase.mk | 5 +++-- + debian/system/core/libcutils.mk | 5 +++-- + debian/system/core/liblog.mk | 3 ++- + debian/system/core/libsparse.mk | 5 +++-- + debian/system/core/libutils.mk | 4 ++-- + debian/system/core/libziparchive.mk | 5 +++-- + debian/system/core/simg2img.mk | 2 +- + debian/system/core/simg2simg.mk | 2 +- + debian/system/extras/libext4_utils.mk | 1 - + frameworks/native/libs/adbd_auth/adbd_auth.cpp | 2 ++ + system/core/adb/adb_listeners.cpp | 12 ++++++------ + system/core/adb/transport_local.cpp | 2 +- + 20 files changed, 35 insertions(+), 34 deletions(-) + +diff --git a/debian/development/etc1tool.mk b/debian/development/etc1tool.mk +index 2d787e98bb86..e03ac5f0048c 100644 +--- a/debian/development/etc1tool.mk ++++ b/debian/development/etc1tool.mk +@@ -4,7 +4,6 @@ SOURCES = development/tools/etc1tool/etc1tool.cpp + + CXXFLAGS += -std=gnu++2a + CPPFLAGS += \ +- -I/usr/include/android \ + -Idevelopment/include \ + -Iframeworks/native/opengl/include \ + +diff --git a/debian/external/boringssl/libcrypto.mk b/debian/external/boringssl/libcrypto.mk +index c0ea54f4..b3a77bfd 100644 +--- a/debian/external/boringssl/libcrypto.mk ++++ b/debian/external/boringssl/libcrypto.mk +@@ -27,6 +27,7 @@ CPPFLAGS += \ + -DBORINGSSL_IMPLEMENTATION \ + -DBORINGSSL_SHARED_LIBRARY \ + -DOPENSSL_SMALL \ ++ -DOPENSSL_NO_ASM \ + -Iexternal/boringssl/src/crypto \ + -Iexternal/boringssl/src/include \ + +diff --git a/debian/libnativehelper/libnativehelper.mk b/debian/libnativehelper/libnativehelper.mk +index 7a0c94a6b7b5..880b2fdf9154 100644 +--- a/debian/libnativehelper/libnativehelper.mk ++++ b/debian/libnativehelper/libnativehelper.mk +@@ -11,7 +11,6 @@ OBJECTS = $(SOURCES:.cpp=.o) + + CXXFLAGS += -std=gnu++2a + CPPFLAGS += \ +- -I/usr/include/android \ + -Ilibnativehelper/header_only_include \ + -Ilibnativehelper/include \ + -Ilibnativehelper/include_jni \ +diff --git a/debian/system/core/adb.mk b/debian/system/core/adb.mk +index 9769b68ab793..58c9a63bd225 100644 +--- a/debian/system/core/adb.mk ++++ b/debian/system/core/adb.mk +@@ -19,7 +19,6 @@ CPPFLAGS += \ + -D_GNU_SOURCE \ + -DADB_HOST=1 \ + -DADB_VERSION='"$(DEB_VERSION)"' \ +- -I/usr/include/android \ + -Iexternal/boringssl/include \ + -Isystem/core/adb \ + -Isystem/core/base/include \ +@@ -28,7 +27,6 @@ CPPFLAGS += \ + LDFLAGS += \ + -Ldebian/out/system/core \ + -Wl,-rpath=/usr/lib/$(DEB_HOST_MULTIARCH)/android \ +- -fuse-ld=gold \ + -lbase \ + -lcutils \ + -lpthread \ +diff --git a/debian/system/core/append2simg.mk b/debian/system/core/append2simg.mk +index 1599bdb8..598c751d 100644 +--- a/debian/system/core/append2simg.mk ++++ b/debian/system/core/append2simg.mk +@@ -11,7 +11,7 @@ CPPFLAGS += \ + + LDFLAGS += \ + -Ldebian/out/system/core \ +- -Wl,-rpath=/usr/lib/$(DEB_HOST_MULTIARCH)/android \ ++ -Wl,-rpath='$$ORIGIN/../lib/android' \ + -lbase \ + -llog \ + -lpthread \ +diff --git a/debian/system/core/fastboot.mk b/debian/system/core/fastboot.mk +index d5c9a285..a59ba1a4 100644 +--- a/debian/system/core/fastboot.mk ++++ b/debian/system/core/fastboot.mk +@@ -30,7 +30,6 @@ CXXFLAGS += -std=gnu++2a -fpermissive + CPPFLAGS += \ + -D_FILE_OFFSET_BITS=64 \ + -DPLATFORM_TOOLS_VERSION='"$(PLATFORM_TOOLS_VERSION)"' \ +- -I/usr/include/android \ + -Iexternal/boringssl/include \ + -Iexternal/avb \ + -Isystem/core/adb \ +@@ -49,8 +48,7 @@ CPPFLAGS += \ + + LDFLAGS += \ + -Ldebian/out/system/core \ +- -Wl,-rpath=/usr/lib/$(DEB_HOST_MULTIARCH)/android \ +- -fuse-ld=gold \ ++ -Wl,-rpath='$$ORIGIN/../lib/android' \ + -lbase \ + -lcutils \ + -lpthread \ +diff --git a/debian/system/core/img2simg.mk b/debian/system/core/img2simg.mk +index 11adf014..8baf5ba5 100644 +--- a/debian/system/core/img2simg.mk ++++ b/debian/system/core/img2simg.mk +@@ -11,7 +11,7 @@ CPPFLAGS += \ + + LDFLAGS += \ + -Ldebian/out/system/core \ +- -Wl,-rpath=/usr/lib/$(DEB_HOST_MULTIARCH)/android \ ++ -Wl,-rpath='$$ORIGIN/../lib/android' \ + -lbase \ + -llog \ + -lpthread \ +diff --git a/debian/system/core/libbacktrace.mk b/debian/system/core/libbacktrace.mk +index e3411d76..e7dd984c 100644 +--- a/debian/system/core/libbacktrace.mk ++++ b/debian/system/core/libbacktrace.mk +@@ -1,4 +1,4 @@ +-include /usr/share/dpkg/architecture.mk ++include rules_yocto.mk + + NAME = libbacktrace + +@@ -81,12 +81,10 @@ CPPFLAGS += \ + -Isystem/core/libunwindstack/include \ + + LDFLAGS += \ +- -L/usr/lib/p7zip \ + -Ldebian/out/system/core \ +- -Wl,-rpath=/usr/lib/p7zip \ +- -Wl,-rpath=/usr/lib/$(DEB_HOST_MULTIARCH)/android \ ++ -Wl,-rpath='$$ORIGIN' \ + -Wl,-soname,$(NAME).so.0 \ +- -l:7z.so \ ++ -l7z \ + -lbase \ + -llog \ + -lpthread \ +@@ -101,7 +99,7 @@ endif + build: $(OBJECTS_CXX) $(OBJECTS_ASSEMBLY) debian/out/external/libunwind/libunwind.a + mkdir -p debian/out/system/core + $(CXX) $^ -o debian/out/system/core/$(NAME).so.0 $(LDFLAGS) +- cd debian/out/system/core && ln -s $(NAME).so.0 $(NAME).so ++ cd debian/out/system/core && ln -sf $(NAME).so.0 $(NAME).so + + $(OBJECTS_CXX): %.o: %.cpp + $(CXX) -c -o $@ $< $(CXXFLAGS) $(CPPFLAGS) +diff --git a/debian/system/core/libbase.mk b/debian/system/core/libbase.mk +index d2b074ba..8a90d6de 100644 +--- a/debian/system/core/libbase.mk ++++ b/debian/system/core/libbase.mk +@@ -1,3 +1,4 @@ ++include rules_yocto.mk + NAME = libbase + + SOURCES = \ +@@ -30,7 +31,7 @@ CPPFLAGS += \ + + LDFLAGS += \ + -Ldebian/out/system/core \ +- -Wl,-rpath=/usr/lib/$(DEB_HOST_MULTIARCH)/android \ ++ -Wl,-rpath='$$ORIGIN' \ + -Wl,-soname,$(NAME).so.0 \ + -llog \ + -lpthread \ +@@ -44,7 +45,7 @@ endif + + build: $(OBJECTS) + $(CXX) $^ -o debian/out/system/core/$(NAME).so.0 $(LDFLAGS) +- cd debian/out/system/core && ln -s $(NAME).so.0 $(NAME).so ++ cd debian/out/system/core && ln -sf $(NAME).so.0 $(NAME).so + + $(OBJECTS): %.o: %.cpp + $(CXX) -c -o $@ $< $(CXXFLAGS) $(CPPFLAGS) +diff --git a/debian/system/core/libcutils.mk b/debian/system/core/libcutils.mk +index 9d928b56..c22b0965 100644 +--- a/debian/system/core/libcutils.mk ++++ b/debian/system/core/libcutils.mk +@@ -1,3 +1,4 @@ ++include rules_yocto.mk + NAME = libcutils + + libcutils_nonwindows_sources = \ +@@ -47,7 +48,7 @@ CPPFLAGS += \ + + LDFLAGS += \ + -Ldebian/out/system/core \ +- -Wl,-rpath=/usr/lib/$(DEB_HOST_MULTIARCH)/android \ ++ -Wl,-rpath='$$ORIGIN' \ + -Wl,-soname,$(NAME).so.0 \ + -lbase \ + -llog \ +@@ -56,7 +57,7 @@ LDFLAGS += \ + + build: $(OBJECTS_C) $(OBJECTS_CXX) + $(CXX) $^ -o debian/out/system/core/$(NAME).so.0 $(LDFLAGS) +- cd debian/out/system/core && ln -s $(NAME).so.0 $(NAME).so ++ cd debian/out/system/core && ln -sf $(NAME).so.0 $(NAME).so + + $(OBJECTS_C): %.o: %.c + $(CC) -c -o $@ $< $(CFLAGS) $(CPPFLAGS) +diff --git a/debian/system/core/liblog.mk b/debian/system/core/liblog.mk +index f8c3d7fe..34a07341 100644 +--- a/debian/system/core/liblog.mk ++++ b/debian/system/core/liblog.mk +@@ -1,3 +1,4 @@ ++include rules_yocto.mk + NAME = liblog + + liblog_sources = \ +@@ -35,7 +36,7 @@ LDFLAGS += \ + build: $(OBJECTS) + mkdir -p debian/out/system/core + $(CXX) $^ -o debian/out/system/core/$(NAME).so.0 $(LDFLAGS) +- cd debian/out/system/core && ln -s $(NAME).so.0 $(NAME).so ++ cd debian/out/system/core && ln -sf $(NAME).so.0 $(NAME).so + + $(OBJECTS): %.o: %.cpp + $(CXX) -c -o $@ $< $(CXXFLAGS) $(CPPFLAGS) +diff --git a/debian/system/core/libsparse.mk b/debian/system/core/libsparse.mk +index c2b2694c..2da12b8e 100644 +--- a/debian/system/core/libsparse.mk ++++ b/debian/system/core/libsparse.mk +@@ -1,3 +1,4 @@ ++include rules_yocto.mk + NAME = libsparse + + SOURCES = \ +@@ -19,7 +20,7 @@ CPPFLAGS += \ + + LDFLAGS += \ + -Ldebian/out/system/core \ +- -Wl,-rpath=/usr/lib/$(DEB_HOST_MULTIARCH)/android \ ++ -Wl,-rpath='$$ORIGIN' \ + -Wl,-soname,$(NAME).so.0 \ + -lbase \ + -lz \ +@@ -27,7 +28,7 @@ LDFLAGS += \ + + build: $(OBJECTS) + $(CXX) $^ -o debian/out/system/core/$(NAME).so.0 $(LDFLAGS) +- cd debian/out/system/core && ln -s $(NAME).so.0 $(NAME).so ++ cd debian/out/system/core && ln -sf $(NAME).so.0 $(NAME).so + + $(OBJECTS): %.o: %.cpp + $(CXX) -c -o $@ $< $(CXXFLAGS) $(CPPFLAGS) +diff --git a/debian/system/core/libutils.mk b/debian/system/core/libutils.mk +index c37b1d2d..0c748c8b 100644 +--- a/debian/system/core/libutils.mk ++++ b/debian/system/core/libutils.mk +@@ -1,4 +1,4 @@ +-include /usr/share/dpkg/architecture.mk ++include rules_yocto.mk + + NAME = libutils + +@@ -41,7 +41,7 @@ CPPFLAGS += \ + + LDFLAGS += \ + -Ldebian/out/system/core \ +- -Wl,-rpath=/usr/lib/$(DEB_HOST_MULTIARCH)/android \ ++ -Wl,-rpath='$$ORIGIN' \ + -Wl,-soname,$(NAME).so.0 \ + -lbacktrace \ + -lcutils \ +diff --git a/debian/system/core/libziparchive.mk b/debian/system/core/libziparchive.mk +index 1b286b4e..1b7499be 100644 +--- a/debian/system/core/libziparchive.mk ++++ b/debian/system/core/libziparchive.mk +@@ -1,3 +1,4 @@ ++include rules_yocto.mk + NAME = libziparchive + + SOURCES = \ +@@ -19,7 +20,7 @@ CPPFLAGS += \ + + LDFLAGS += \ + -Ldebian/out/system/core \ +- -Wl,-rpath=/usr/lib/$(DEB_HOST_MULTIARCH)/android \ ++ -Wl,-rpath='$$ORIGIN' \ + -Wl,-soname,$(NAME).so.0 \ + -lbase \ + -llog \ +@@ -29,7 +30,7 @@ LDFLAGS += \ + + build: $(OBJECTS) + $(CXX) $^ -o debian/out/system/core/$(NAME).so.0 $(LDFLAGS) +- cd debian/out/system/core && ln -s $(NAME).so.0 $(NAME).so ++ cd debian/out/system/core && ln -sf $(NAME).so.0 $(NAME).so + + $(OBJECTS): %.o: %.cc + $(CXX) -c -o $@ $< $(CXXFLAGS) $(CPPFLAGS) +diff --git a/debian/system/core/simg2img.mk b/debian/system/core/simg2img.mk +index f6e3f59d..df4f44f3 100644 +--- a/debian/system/core/simg2img.mk ++++ b/debian/system/core/simg2img.mk +@@ -13,7 +13,7 @@ CPPFLAGS += \ + + LDFLAGS += \ + -Ldebian/out/system/core \ +- -Wl,-rpath=/usr/lib/$(DEB_HOST_MULTIARCH)/android \ ++ -Wl,-rpath='$$ORIGIN/../lib/android' \ + -lbase \ + -llog \ + -lpthread \ +diff --git a/debian/system/core/simg2simg.mk b/debian/system/core/simg2simg.mk +index ed53b04c..646ab030 100644 +--- a/debian/system/core/simg2simg.mk ++++ b/debian/system/core/simg2simg.mk +@@ -13,7 +13,7 @@ CPPFLAGS += \ + + LDFLAGS += \ + -Ldebian/out/system/core \ +- -Wl,-rpath=/usr/lib/$(DEB_HOST_MULTIARCH)/android \ ++ -Wl,-rpath='$$ORIGIN/../lib/android' \ + -lbase \ + -llog \ + -lpthread \ +diff --git a/debian/system/extras/libext4_utils.mk b/debian/system/extras/libext4_utils.mk +index 264bb95ad36a..99125097c8e3 100644 +--- a/debian/system/extras/libext4_utils.mk ++++ b/debian/system/extras/libext4_utils.mk +@@ -25,7 +25,6 @@ CPPFLAGS += \ + -D_LARGEFILE64_SOURCE \ + -DFEC_NO_KLOG \ + -DSQUASHFS_NO_KLOG \ +- -I/usr/include/android \ + -Isystem/core/base/include \ + -Isystem/core/libcutils/include \ + -Isystem/core/libsparse/include \ +diff --git a/frameworks/native/libs/adbd_auth/adbd_auth.cpp b/frameworks/native/libs/adbd_auth/adbd_auth.cpp +index a9c23110..6ca334ba 100644 +--- a/frameworks/native/libs/adbd_auth/adbd_auth.cpp ++++ b/frameworks/native/libs/adbd_auth/adbd_auth.cpp +@@ -23,8 +23,10 @@ + #include + #include + ++#include + #include + #include ++#include + #include + #include + #include +diff --git a/system/core/adb/adb_listeners.cpp b/system/core/adb/adb_listeners.cpp +index 29909a55..440cdbd4 100644 +--- a/system/core/adb/adb_listeners.cpp ++++ b/system/core/adb/adb_listeners.cpp +@@ -109,7 +109,7 @@ static void listener_event_func(int _fd, unsigned ev, void* _l) + } + + // Called as a transport disconnect function. |arg| is the raw alistener*. +-static void listener_disconnect(void* arg, atransport*) EXCLUDES(listener_list_mutex) { ++static void listener_disconnect(void* arg, atransport*) { + std::lock_guard lock(listener_list_mutex); + for (auto iter = listener_list.begin(); iter != listener_list.end(); ++iter) { + if (iter->get() == arg) { +@@ -121,7 +121,7 @@ static void listener_disconnect(void* arg, atransport*) EXCLUDES(listener_list_m + } + + // Write the list of current listeners (network redirections) into a string. +-std::string format_listeners() EXCLUDES(listener_list_mutex) { ++std::string format_listeners() { + std::lock_guard lock(listener_list_mutex); + std::string result; + for (auto& l : listener_list) { +@@ -140,7 +140,7 @@ std::string format_listeners() EXCLUDES(listener_list_mutex) { + } + + InstallStatus remove_listener(const char* local_name, atransport* transport) +- EXCLUDES(listener_list_mutex) { ++{ + std::lock_guard lock(listener_list_mutex); + for (auto iter = listener_list.begin(); iter != listener_list.end(); ++iter) { + if (local_name == (*iter)->local_name) { +@@ -151,7 +151,7 @@ InstallStatus remove_listener(const char* local_name, atransport* transport) + return INSTALL_STATUS_LISTENER_NOT_FOUND; + } + +-void remove_all_listeners() EXCLUDES(listener_list_mutex) { ++void remove_all_listeners() { + std::lock_guard lock(listener_list_mutex); + auto iter = listener_list.begin(); + while (iter != listener_list.end()) { +@@ -164,7 +164,7 @@ void remove_all_listeners() EXCLUDES(listener_list_mutex) { + } + } + +-void close_smartsockets() EXCLUDES(listener_list_mutex) { ++void close_smartsockets() { + std::lock_guard lock(listener_list_mutex); + auto pred = [](const std::unique_ptr& listener) { + return listener->local_name == "*smartsocket*"; +@@ -174,7 +174,7 @@ void close_smartsockets() EXCLUDES(listener_list_mutex) { + + InstallStatus install_listener(const std::string& local_name, const char* connect_to, + atransport* transport, int no_rebind, int* resolved_tcp_port, +- std::string* error) EXCLUDES(listener_list_mutex) { ++ std::string* error) { + std::lock_guard lock(listener_list_mutex); + for (auto& l : listener_list) { + if (local_name == l->local_name) { +diff --git a/system/core/adb/transport_local.cpp b/system/core/adb/transport_local.cpp +index c7261860..5988ec4d 100644 +--- a/system/core/adb/transport_local.cpp ++++ b/system/core/adb/transport_local.cpp +@@ -333,7 +333,7 @@ struct EmulatorConnection : public FdConnection { + + /* Only call this function if you already hold local_transports_lock. */ + static atransport* find_emulator_transport_by_adb_port_locked(int adb_port) +- REQUIRES(local_transports_lock) { ++{ + auto it = local_transports.find(adb_port); + if (it == local_transports.end()) { + return nullptr; +-- +2.34.1 + diff --git a/meta-oe/recipes-devtools/android-tools/android-tools/0003-Update-usage-of-usbdevfs_urb-to-match-new-kernel-UAP.patch b/meta-oe/recipes-devtools/android-tools/android-tools/0003-Update-usage-of-usbdevfs_urb-to-match-new-kernel-UAP.patch new file mode 100644 index 0000000000..ea934f44d8 --- /dev/null +++ b/meta-oe/recipes-devtools/android-tools/android-tools/0003-Update-usage-of-usbdevfs_urb-to-match-new-kernel-UAP.patch @@ -0,0 +1,128 @@ +From 02b6b6977d80af4b9b806054fadb5a06cedf011d Mon Sep 17 00:00:00 2001 +From: Etienne Cordonnier +Date: Tue, 14 Mar 2023 11:33:50 +0100 +Subject: [PATCH] Update usage of usbdevfs_urb to match new kernel UAPI +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Linux kernel API has been changed by commit 94dfc73e7cf4 ("treewide: uapi: Replace zero-length arrays with flexible-array members") +where zero-length array iso_frame_desc in struct usbdevfs_urb was replaced with a proper flexible-array member. + +Current USB API usage causes a compilation error at Linux 6.0: + +In file included from /home/mae/.cache/kiss/proc/121205/build/android-tools/vendor/adb/client/usb_linux.cpp:28: +/usr/include/linux/usbdevice_fs.h:134:41: error: flexible array member ‘usbdevfs_urb::iso_frame_desc’ not at end of ‘struct usb_handle’ + 134 | struct usbdevfs_iso_packet_desc iso_frame_desc[]; + | ^~~~~~~~~~~~~~ +/home/mae/.cache/kiss/proc/121205/build/android-tools/vendor/adb/client/usb_linux.cpp:76:18: note: next member ‘usbdevfs_urb usb_handle::urb_out’ declared here + 76 | usbdevfs_urb urb_out; + | ^~~~~~~ +/home/mae/.cache/kiss/proc/121205/build/android-tools/vendor/adb/client/usb_linux.cpp:61:8: note: in the definition of ‘struct usb_handle’ + 61 | struct usb_handle { + | ^~~~~~~~~~ + +Fix it by using pointers to a struct with flexible-array members. +Current fix works both with the old and the new API. + +See https://github.com/nmeum/android-tools/issues/74 for more context. + +Tested: built on Linux against kernel 5.19 and 6.0; 'adb shell' over USB +cable +Acked-by: Gustavo A. R. Silva gustavoars@kernel.org +Change-Id: I7f0f7b35d9a3ab980d3520b541b60c7857a6b101 +Signed-off-by: Anatol Pomozov + +[Backported on version 10] +Signed-off-by: Etienne Cordonnier + +--- +Upstream-Status: Pending + + system/core/adb/client/usb_linux.cpp | 24 ++++++++++++++---------- + 1 file changed, 14 insertions(+), 10 deletions(-) + +diff --git a/system/core/adb/client/usb_linux.cpp b/system/core/adb/client/usb_linux.cpp +index 343e7b59..6a4479f3 100644 +--- a/system/core/adb/client/usb_linux.cpp ++++ b/system/core/adb/client/usb_linux.cpp +@@ -71,8 +71,8 @@ struct usb_handle : public ::usb_handle { + unsigned zero_mask; + unsigned writeable = 1; + +- usbdevfs_urb urb_in; +- usbdevfs_urb urb_out; ++ usbdevfs_urb *urb_in; ++ usbdevfs_urb *urb_out; + + bool urb_in_busy = false; + bool urb_out_busy = false; +@@ -305,7 +305,7 @@ static int usb_bulk_write(usb_handle* h, const void* data, int len) { + std::unique_lock lock(h->mutex); + D("++ usb_bulk_write ++"); + +- usbdevfs_urb* urb = &h->urb_out; ++ usbdevfs_urb* urb = h->urb_out; + memset(urb, 0, sizeof(*urb)); + urb->type = USBDEVFS_URB_TYPE_BULK; + urb->endpoint = h->ep_out; +@@ -344,7 +344,7 @@ static int usb_bulk_read(usb_handle* h, void* data, int len) { + std::unique_lock lock(h->mutex); + D("++ usb_bulk_read ++"); + +- usbdevfs_urb* urb = &h->urb_in; ++ usbdevfs_urb* urb = h->urb_in; + memset(urb, 0, sizeof(*urb)); + urb->type = USBDEVFS_URB_TYPE_BULK; + urb->endpoint = h->ep_in; +@@ -389,7 +389,7 @@ static int usb_bulk_read(usb_handle* h, void* data, int len) { + } + D("[ urb @%p status = %d, actual = %d ]", out, out->status, out->actual_length); + +- if (out == &h->urb_in) { ++ if (out == h->urb_in) { + D("[ reap urb - IN complete ]"); + h->urb_in_busy = false; + if (urb->status != 0) { +@@ -398,7 +398,7 @@ static int usb_bulk_read(usb_handle* h, void* data, int len) { + } + return urb->actual_length; + } +- if (out == &h->urb_out) { ++ if (out == h->urb_out) { + D("[ reap urb - OUT compelete ]"); + h->urb_out_busy = false; + h->cv.notify_all(); +@@ -502,10 +502,10 @@ void usb_kick(usb_handle* h) { + ** but this ensures that a reader blocked on REAPURB + ** will get unblocked + */ +- ioctl(h->fd, USBDEVFS_DISCARDURB, &h->urb_in); +- ioctl(h->fd, USBDEVFS_DISCARDURB, &h->urb_out); +- h->urb_in.status = -ENODEV; +- h->urb_out.status = -ENODEV; ++ ioctl(h->fd, USBDEVFS_DISCARDURB, h->urb_in); ++ ioctl(h->fd, USBDEVFS_DISCARDURB, h->urb_out); ++ h->urb_in->status = -ENODEV; ++ h->urb_out->status = -ENODEV; + h->urb_in_busy = false; + h->urb_out_busy = false; + h->cv.notify_all(); +@@ -521,6 +521,8 @@ int usb_close(usb_handle* h) { + + D("-- usb close %p (fd = %d) --", h, h->fd); + ++ delete h->urb_in; ++ delete h->urb_out; + delete h; + + return 0; +@@ -556,6 +558,8 @@ static void register_device(const char* dev_name, const char* dev_path, unsigned + usb->ep_out = ep_out; + usb->zero_mask = zero_mask; + usb->max_packet_size = max_packet_size; ++ usb->urb_in = new usbdevfs_urb; ++ usb->urb_out = new usbdevfs_urb; + + // Initialize mark so we don't get garbage collected after the device scan. + usb->mark = true; diff --git a/meta-oe/recipes-devtools/android-tools/android-tools/0004-adb-Fix-build-on-big-endian-systems.patch b/meta-oe/recipes-devtools/android-tools/android-tools/0004-adb-Fix-build-on-big-endian-systems.patch new file mode 100644 index 0000000000..c82423908f --- /dev/null +++ b/meta-oe/recipes-devtools/android-tools/android-tools/0004-adb-Fix-build-on-big-endian-systems.patch @@ -0,0 +1,50 @@ +From e4a29888cb52c1eafd3ab57a6e220b38147ecfbe Mon Sep 17 00:00:00 2001 +From: Etienne Cordonnier +Date: Tue, 14 Mar 2023 13:39:23 +0100 +Subject: [PATCH] adb: Fix build on big endian systems + +The usb_linux_client.c file defines cpu_to_le16/32 by using the C +library htole16/32 function calls. However, cpu_to_le16/32 are used +when initializing structures, i.e in a context where a function call +is not allowed. + +It works fine on little endian systems because htole16/32 are defined +by the C library as no-ops. But on big-endian systems, they are +actually doing something, which might involve calling a function, +causing build failures. + +To solve this, we simply open-code cpu_to_le16/32 in a way that allows +them to be used when initializing structures. + +Signed-off-by: Thomas Petazzoni +[Forward-ported to version 29] +Signed-off-by: Etienne Cordonnier + +--- +Upstream-Status: Pending + + system/core/adb/daemon/usb_ffs.cpp | 11 +++++++++-- + 1 file changed, 9 insertions(+), 2 deletions(-) + +diff --git a/system/core/adb/daemon/usb_ffs.cpp b/system/core/adb/daemon/usb_ffs.cpp +index b19fa5d5..ef2291ca 100644 +--- a/system/core/adb/daemon/usb_ffs.cpp ++++ b/system/core/adb/daemon/usb_ffs.cpp +@@ -39,8 +39,15 @@ + + #define USB_EXT_PROP_UNICODE 1 + +-#define cpu_to_le16(x) htole16(x) +-#define cpu_to_le32(x) htole32(x) ++#if __BYTE_ORDER == __LITTLE_ENDIAN ++# define cpu_to_le16(x) (x) ++# define cpu_to_le32(x) (x) ++#else ++# define cpu_to_le16(x) ((((x) >> 8) & 0xffu) | (((x) & 0xffu) << 8)) ++# define cpu_to_le32(x) \ ++ ((((x) & 0xff000000u) >> 24) | (((x) & 0x00ff0000u) >> 8) | \ ++ (((x) & 0x0000ff00u) << 8) | (((x) & 0x000000ffu) << 24)) ++#endif + + // clang-format off + struct func_desc { diff --git a/meta-oe/recipes-devtools/android-tools/android-tools/0005-adb-Allow-adbd-to-be-run-as-root.patch b/meta-oe/recipes-devtools/android-tools/android-tools/0005-adb-Allow-adbd-to-be-run-as-root.patch new file mode 100644 index 0000000000..dfbdc2af66 --- /dev/null +++ b/meta-oe/recipes-devtools/android-tools/android-tools/0005-adb-Allow-adbd-to-be-run-as-root.patch @@ -0,0 +1,25 @@ +From 4ef35041ba5c02df48c31f2382e7c3c4316ad936 Mon Sep 17 00:00:00 2001 +From: Etienne Cordonnier +Date: Tue, 14 Mar 2023 13:53:51 +0100 +Subject: [PATCH] adb: Allow adbd to be run as root + +Signed-off-by: Etienne Cordonnier + +--- +Upstream-Status: Pending + + system/core/adb/daemon/main.cpp | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/system/core/adb/daemon/main.cpp b/system/core/adb/daemon/main.cpp +index e807d13d..309663a2 100644 +--- a/system/core/adb/daemon/main.cpp ++++ b/system/core/adb/daemon/main.cpp +@@ -75,6 +75,7 @@ static bool should_drop_capabilities_bounding_set() { + } + + static bool should_drop_privileges() { ++ return true; + // "adb root" not allowed, always drop privileges. + if (!ALLOW_ADBD_ROOT && !is_device_unlocked()) return true; + diff --git a/meta-oe/recipes-devtools/android-tools/android-tools/adbd.mk b/meta-oe/recipes-devtools/android-tools/android-tools/adbd.mk new file mode 100644 index 0000000000..3282216b8e --- /dev/null +++ b/meta-oe/recipes-devtools/android-tools/android-tools/adbd.mk @@ -0,0 +1,87 @@ +include rules_yocto.mk +NAME = adbd + +SOURCES = \ + adb/adbconnection/adbconnection_server.cpp \ + adb/daemon/auth.cpp \ + adb/daemon/file_sync_service.cpp \ + adb/daemon/file_sync_service.h \ + adb/daemon/framebuffer_service.cpp \ + adb/daemon/framebuffer_service.h \ + adb/daemon/jdwp_service.cpp \ + adb/daemon/main.cpp \ + adb/daemon/restart_service.cpp \ + adb/daemon/restart_service.h \ + adb/daemon/services.cpp \ + adb/daemon/shell_service.cpp \ + adb/daemon/shell_service.h \ + adb/daemon/usb_ffs.cpp \ + adb/daemon/usb_legacy.cpp \ + adb/daemon/usb.cpp \ + adb/shell_service_protocol.cpp \ + adb/adb.cpp \ + adb/adb_io.cpp \ + adb/adb_listeners.cpp \ + adb/adb_trace.cpp \ + adb/adb_unique_fd.cpp \ + adb/adb_utils.cpp \ + adb/fdevent/fdevent.cpp \ + adb/fdevent/fdevent_epoll.cpp \ + adb/services.cpp \ + adb/sockets.cpp \ + adb/socket_spec.cpp \ + adb/sysdeps/errno.cpp \ + adb/sysdeps/posix/network.cpp \ + adb/sysdeps_unix.cpp \ + adb/transport.cpp \ + adb/transport_fd.cpp \ + adb/transport_local.cpp \ + adb/transport_usb.cpp \ + adb/types.cpp \ + diagnose_usb/diagnose_usb.cpp \ + libasyncio/AsyncIO.cpp \ + +SOURCES := $(foreach source, $(SOURCES), system/core/$(source)) + +SOURCES += \ + frameworks/native/libs/adbd_auth/adbd_auth.cpp + +CXXFLAGS += -std=gnu++20 +CPPFLAGS += -Isystem/coreinclude -Isystem/core/adb -Isystem/core/base/include -Idebian/out/system/core -Isystem/tools/mkbootimg/include/bootimg -Isystem/core/fs_mgr/include \ + -Isystem/core/fs_mgr/include_fstab \ + -DADB_VERSION='"$(DEB_VERSION)"' -D_GNU_SOURCE +LDFLAGS += -Wl,-rpath='$$ORIGIN/../lib/android' -Wl,-rpath-link='$$ORIGIN/../lib/android' \ + -lpthread -Ldebian/out/system/core -Ldebian/out/external/boringssl -lbase -lcrypto_utils -l:libcrypto.a -lcutils -llog -lresolv + +PAGE_SIZE ?= 4096 + +CXXFLAGS += -UADB_HOST +CXXFLAGS += -DADB_HOST=0 +CXXFLAGS += -DALLOW_ADBD_DISABLE_VERITY +CXXFLAGS += -DALLOW_ADBD_NO_AUTH +CXXFLAGS += -DPLATFORM_TOOLS_VERSION='"28.0.2"' +CXXFLAGS += -Isystem/core/diagnose_usb/include +CXXFLAGS += -Isystem/core/adb/daemon/include +CXXFLAGS += -Isystem/core/adb/adbconnection/include +CXXFLAGS += -Isystem/core/libasyncio/include +CXXFLAGS += -Isystem/core/libcutils/include +CXXFLAGS += -Isystem/core/libcrypto_utils/include +CXXFLAGS += -Isystem/core/liblog/include/ +CXXFLAGS += -Isystem/core/libutils/include +CXXFLAGS += -Iframeworks/native/libs/adbd_auth/include +CXXFLAGS += -Wno-c++11-narrowing +CXXFLAGS += -DPAGE_SIZE=$(PAGE_SIZE) + + +# -latomic should be the last library specified +# https://github.com/android/ndk/issues/589 +ifneq ($(filter armel mipsel,$(DEB_HOST_ARCH)),) + LDFLAGS += -latomic +endif + +build: $(SOURCES) + mkdir --parents debian/out/system/core + $(CXX) $^ -o debian/out/system/core/adbd $(CXXFLAGS) $(CPPFLAGS) $(LDFLAGS) + +clean: + $(RM) debian/out/system/core/adbd diff --git a/meta-oe/recipes-devtools/android-tools/android-tools/android-tools-adbd.service b/meta-oe/recipes-devtools/android-tools/android-tools/android-tools-adbd.service new file mode 100644 index 0000000000..b6661f2e39 --- /dev/null +++ b/meta-oe/recipes-devtools/android-tools/android-tools/android-tools-adbd.service @@ -0,0 +1,13 @@ +[Unit] +Description=Android Debug Bridge +ConditionPathExists=/etc/usb-debugging-enabled +Before=android-system.service + +[Service] +Type=simple +Restart=on-failure +ExecStartPre=-/usr/bin/android-gadget-setup adb +ExecStart=/usr/bin/adbd + +[Install] +WantedBy=basic.target diff --git a/meta-oe/recipes-devtools/android-tools/android-tools/debian/Add-riscv64-support.patch b/meta-oe/recipes-devtools/android-tools/android-tools/debian/Add-riscv64-support.patch new file mode 100644 index 0000000000..9fd0fa792c --- /dev/null +++ b/meta-oe/recipes-devtools/android-tools/android-tools/debian/Add-riscv64-support.patch @@ -0,0 +1,653 @@ +From: Guo Ren +Date: Wed, 29 Jun 2022 16:46:46 +0800 +Subject: Add riscv64 support + +This patch contains the dwarf unwind support for 64bit risc-v. + + * DwarfCfa.cpp (cfa_def_cfa_register): setup register if CFA_REG is + not setup for riscv64 + * Elf.cpp (GetRelPc): convert offset to virtual address for riscv64. + * ElfInterface.cpp (GetVirtAddrFromOffset): New for riscv64. + * RegsRiscv64.cpp (StepIfSignalHandler): Fix signal frame check. + libunwindstack/include/unwindstack/ + * ElfInterface.h (GetVirtAddrFromOffset): New for riscv64. + libunwindstack/tests/ + * DwarfCfaTest.cpp (cfa_def_cfa_register): ok for riscv64. + * RegsStepIfSignalHandlerTest.cpp (riscv64_step_if_signal_handler): Fix + testcase for riscv64 + +Test: Builds. +Test: All unit tests pass. + +Signed-off-by: Guo Ren +Signed-off-by: Lifang Xia +Signed-off-by: Mao Han +Change-Id: Ib21ddf23cc83f332af202df7bffcaceec16063e0 +--- +Upstream-Status: Pending + + system/core/libunwindstack/Android.bp | 1 + + system/core/libunwindstack/Elf.cpp | 2 + + system/core/libunwindstack/Regs.cpp | 10 ++ + system/core/libunwindstack/RegsRiscv64.cpp | 156 +++++++++++++++++++++ + .../core/libunwindstack/include/unwindstack/Elf.h | 5 + + .../include/unwindstack/MachineRiscv64.h | 59 ++++++++ + .../include/unwindstack/RegsGetLocal.h | 43 ++++++ + .../include/unwindstack/RegsRiscv64.h | 59 ++++++++ + .../include/unwindstack/UcontextRiscv64.h | 80 +++++++++++ + .../include/unwindstack/UserRiscv64.h | 37 +++++ + system/core/libunwindstack/tools/unwind.cpp | 3 + + .../core/libunwindstack/tools/unwind_symbols.cpp | 3 + + 12 files changed, 458 insertions(+) + create mode 100644 system/core/libunwindstack/RegsRiscv64.cpp + create mode 100644 system/core/libunwindstack/include/unwindstack/MachineRiscv64.h + create mode 100644 system/core/libunwindstack/include/unwindstack/RegsRiscv64.h + create mode 100644 system/core/libunwindstack/include/unwindstack/UcontextRiscv64.h + create mode 100644 system/core/libunwindstack/include/unwindstack/UserRiscv64.h + +diff --git a/system/core/libunwindstack/Android.bp b/system/core/libunwindstack/Android.bp +index 3695f72..f1f9c68 100644 +--- a/system/core/libunwindstack/Android.bp ++++ b/system/core/libunwindstack/Android.bp +@@ -70,6 +70,7 @@ cc_library { + "RegsArm64.cpp", + "RegsX86.cpp", + "RegsX86_64.cpp", ++ "RegsRiscv64.cpp", + "RegsMips.cpp", + "RegsMips64.cpp", + "Unwinder.cpp", +diff --git a/system/core/libunwindstack/Elf.cpp b/system/core/libunwindstack/Elf.cpp +index f01b092..3c2088b 100644 +--- a/system/core/libunwindstack/Elf.cpp ++++ b/system/core/libunwindstack/Elf.cpp +@@ -290,6 +290,8 @@ ElfInterface* Elf::CreateInterfaceFromMemory(Memory* memory) { + arch_ = ARCH_X86_64; + } else if (e_machine == EM_MIPS) { + arch_ = ARCH_MIPS64; ++ } else if (e_machine == EM_RISCV) { ++ arch_ = ARCH_RISCV64; + } else { + // Unsupported. + ALOGI("64 bit elf that is neither aarch64 nor x86_64 nor mips64: e_machine = %d\n", +diff --git a/system/core/libunwindstack/Regs.cpp b/system/core/libunwindstack/Regs.cpp +index c7dec52..447a554 100644 +--- a/system/core/libunwindstack/Regs.cpp ++++ b/system/core/libunwindstack/Regs.cpp +@@ -27,12 +27,14 @@ + #include + #include + #include ++#include + #include + #include + #include + #include + #include + #include ++#include + #include + #include + +@@ -67,6 +69,8 @@ Regs* Regs::RemoteGet(pid_t pid) { + return RegsMips::Read(buffer.data()); + case sizeof(mips64_user_regs): + return RegsMips64::Read(buffer.data()); ++ case sizeof(riscv64_user_regs): ++ return RegsRiscv64::Read(buffer.data()); + } + return nullptr; + } +@@ -85,6 +89,8 @@ Regs* Regs::CreateFromUcontext(ArchEnum arch, void* ucontext) { + return RegsMips::CreateFromUcontext(ucontext); + case ARCH_MIPS64: + return RegsMips64::CreateFromUcontext(ucontext); ++ case ARCH_RISCV64: ++ return RegsRiscv64::CreateFromUcontext(ucontext); + case ARCH_UNKNOWN: + default: + return nullptr; +@@ -104,6 +110,8 @@ ArchEnum Regs::CurrentArch() { + return ARCH_MIPS; + #elif defined(__mips__) && defined(__LP64__) + return ARCH_MIPS64; ++#elif defined(__riscv) ++ return ARCH_RISCV64; + #else + abort(); + #endif +@@ -123,6 +131,8 @@ Regs* Regs::CreateFromLocal() { + regs = new RegsMips(); + #elif defined(__mips__) && defined(__LP64__) + regs = new RegsMips64(); ++#elif defined(__riscv) ++ regs = new RegsRiscv64(); + #else + abort(); + #endif +diff --git a/system/core/libunwindstack/RegsRiscv64.cpp b/system/core/libunwindstack/RegsRiscv64.cpp +new file mode 100644 +index 0000000..887762a +--- /dev/null ++++ b/system/core/libunwindstack/RegsRiscv64.cpp +@@ -0,0 +1,156 @@ ++/* ++ * Copyright (C) 2022 The Android Open Source Project ++ * ++ * Licensed under the Apache License, Version 2.0 (the "License"); ++ * you may not use this file except in compliance with the License. ++ * You may obtain a copy of the License at ++ * ++ * http://www.apache.org/licenses/LICENSE-2.0 ++ * ++ * Unless required by applicable law or agreed to in writing, software ++ * distributed under the License is distributed on an "AS IS" BASIS, ++ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ++ * See the License for the specific language governing permissions and ++ * limitations under the License. ++ */ ++ ++#include ++#include ++ ++#include ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++ ++namespace unwindstack { ++ ++RegsRiscv64::RegsRiscv64() ++ : RegsImpl(RISCV64_REG_MAX, Location(LOCATION_REGISTER, RISCV64_REG_RA)) {} ++ ++ArchEnum RegsRiscv64::Arch() { ++ return ARCH_RISCV64; ++} ++ ++uint64_t RegsRiscv64::pc() { ++ return regs_[RISCV64_REG_PC]; ++} ++ ++uint64_t RegsRiscv64::sp() { ++ return regs_[RISCV64_REG_SP]; ++} ++ ++void RegsRiscv64::set_pc(uint64_t pc) { ++ regs_[RISCV64_REG_PC] = pc; ++} ++ ++void RegsRiscv64::set_sp(uint64_t sp) { ++ regs_[RISCV64_REG_SP] = sp; ++} ++ ++uint64_t RegsRiscv64::GetPcAdjustment(uint64_t rel_pc, Elf*) { ++ if (rel_pc < 8) { ++ return 0; ++ } ++ // For now, just assume no compact branches ++ return 8; ++} ++ ++bool RegsRiscv64::SetPcFromReturnAddress(Memory*) { ++ uint64_t ra = regs_[RISCV64_REG_RA]; ++ if (regs_[RISCV64_REG_PC] == ra) { ++ return false; ++ } ++ ++ regs_[RISCV64_REG_PC] = ra; ++ return true; ++} ++ ++void RegsRiscv64::IterateRegisters(std::function fn) { ++ fn("pc", regs_[RISCV64_REG_PC]); ++ fn("ra", regs_[RISCV64_REG_RA]); ++ fn("sp", regs_[RISCV64_REG_SP]); ++ fn("gp", regs_[RISCV64_REG_GP]); ++ fn("tp", regs_[RISCV64_REG_TP]); ++ fn("t0", regs_[RISCV64_REG_T0]); ++ fn("t1", regs_[RISCV64_REG_T1]); ++ fn("t2", regs_[RISCV64_REG_T2]); ++ fn("t3", regs_[RISCV64_REG_T3]); ++ fn("t4", regs_[RISCV64_REG_T4]); ++ fn("t5", regs_[RISCV64_REG_T5]); ++ fn("t6", regs_[RISCV64_REG_T6]); ++ fn("s0", regs_[RISCV64_REG_S0]); ++ fn("s1", regs_[RISCV64_REG_S1]); ++ fn("s2", regs_[RISCV64_REG_S2]); ++ fn("s3", regs_[RISCV64_REG_S3]); ++ fn("s4", regs_[RISCV64_REG_S4]); ++ fn("s5", regs_[RISCV64_REG_S5]); ++ fn("s6", regs_[RISCV64_REG_S6]); ++ fn("s7", regs_[RISCV64_REG_S7]); ++ fn("s8", regs_[RISCV64_REG_S8]); ++ fn("s9", regs_[RISCV64_REG_S9]); ++ fn("s10", regs_[RISCV64_REG_S10]); ++ fn("s11", regs_[RISCV64_REG_S11]); ++ fn("a0", regs_[RISCV64_REG_A0]); ++ fn("a1", regs_[RISCV64_REG_A1]); ++ fn("a2", regs_[RISCV64_REG_A2]); ++ fn("a3", regs_[RISCV64_REG_A3]); ++ fn("a4", regs_[RISCV64_REG_A4]); ++ fn("a5", regs_[RISCV64_REG_A5]); ++ fn("a6", regs_[RISCV64_REG_A6]); ++ fn("a7", regs_[RISCV64_REG_A7]); ++} ++ ++Regs* RegsRiscv64::Read(void* remote_data) { ++ riscv64_user_regs* user = reinterpret_cast(remote_data); ++ ++ RegsRiscv64* regs = new RegsRiscv64(); ++ memcpy(regs->RawData(), &user->regs[0], RISCV64_REG_MAX * sizeof(uint64_t)); ++ // uint64_t* reg_data = reinterpret_cast(regs->RawData()); ++ return regs; ++} ++ ++Regs* RegsRiscv64::CreateFromUcontext(void* ucontext) { ++ riscv64_ucontext_t* riscv64_ucontext = reinterpret_cast(ucontext); ++ ++ RegsRiscv64* regs = new RegsRiscv64(); ++ memcpy(regs->RawData(), &riscv64_ucontext->uc_mcontext.__gregs[0], ++ RISCV64_REG_MAX * sizeof(uint64_t)); ++ return regs; ++} ++ ++bool RegsRiscv64::StepIfSignalHandler(uint64_t elf_offset, Elf* elf, Memory* process_memory) { ++ uint64_t data; ++ Memory* elf_memory = elf->memory(); ++ // Read from elf memory since it is usually more expensive to read from ++ // process memory. ++ if (!elf_memory->ReadFully(elf_offset, &data, sizeof(data))) { ++ return false; ++ } ++ // Look for the kernel sigreturn function. ++ // __kernel_rt_sigreturn: ++ // li a7, __NR_rt_sigreturn ++ // scall ++ ++ const uint8_t li_scall[] = {0x93, 0x08, 0xb0, 0x08, 0x73, 0x00, 0x00, 0x00}; ++ if (memcmp(&data, &li_scall, 8) != 0) { ++ return false; ++ } ++ ++ // SP + sizeof(siginfo_t) + uc_mcontext offset + PC offset. ++ if (!process_memory->ReadFully(regs_[RISCV64_REG_SP] + 0x80 + 0xb0 + 0x00, regs_.data(), ++ sizeof(uint64_t) * (RISCV64_REG_MAX))) { ++ return false; ++ } ++ return true; ++} ++ ++Regs* RegsRiscv64::Clone() { ++ return new RegsRiscv64(*this); ++} ++ ++} // namespace unwindstack +diff --git a/system/core/libunwindstack/include/unwindstack/Elf.h b/system/core/libunwindstack/include/unwindstack/Elf.h +index 472ed92..88fa0ff 100644 +--- a/system/core/libunwindstack/include/unwindstack/Elf.h ++++ b/system/core/libunwindstack/include/unwindstack/Elf.h +@@ -32,6 +32,10 @@ + #define EM_AARCH64 183 + #endif + ++#if !defined(EM_RISCV) ++#define EM_RISCV 243 ++#endif ++ + namespace unwindstack { + + // Forward declaration. +@@ -46,6 +50,7 @@ enum ArchEnum : uint8_t { + ARCH_X86_64, + ARCH_MIPS, + ARCH_MIPS64, ++ ARCH_RISCV64, + }; + + class Elf { +diff --git a/system/core/libunwindstack/include/unwindstack/MachineRiscv64.h b/system/core/libunwindstack/include/unwindstack/MachineRiscv64.h +new file mode 100644 +index 0000000..397e680 +--- /dev/null ++++ b/system/core/libunwindstack/include/unwindstack/MachineRiscv64.h +@@ -0,0 +1,59 @@ ++/* ++ * Copyright (C) 2022 The Android Open Source Project ++ * ++ * Licensed under the Apache License, Version 2.0 (the "License"); ++ * you may not use this file except in compliance with the License. ++ * You may obtain a copy of the License at ++ * ++ * http://www.apache.org/licenses/LICENSE-2.0 ++ * ++ * Unless required by applicable law or agreed to in writing, software ++ * distributed under the License is distributed on an "AS IS" BASIS, ++ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ++ * See the License for the specific language governing permissions and ++ * limitations under the License. ++ */ ++ ++#pragma once ++ ++#include ++ ++namespace unwindstack { ++ ++enum Riscv64Reg : uint16_t { ++ RISCV64_REG_PC, ++ RISCV64_REG_RA, ++ RISCV64_REG_SP, ++ RISCV64_REG_GP, ++ RISCV64_REG_TP, ++ RISCV64_REG_T0, ++ RISCV64_REG_T1, ++ RISCV64_REG_T2, ++ RISCV64_REG_S0, ++ RISCV64_REG_S1, ++ RISCV64_REG_A0, ++ RISCV64_REG_A1, ++ RISCV64_REG_A2, ++ RISCV64_REG_A3, ++ RISCV64_REG_A4, ++ RISCV64_REG_A5, ++ RISCV64_REG_A6, ++ RISCV64_REG_A7, ++ RISCV64_REG_S2, ++ RISCV64_REG_S3, ++ RISCV64_REG_S4, ++ RISCV64_REG_S5, ++ RISCV64_REG_S6, ++ RISCV64_REG_S7, ++ RISCV64_REG_S8, ++ RISCV64_REG_S9, ++ RISCV64_REG_S10, ++ RISCV64_REG_S11, ++ RISCV64_REG_T3, ++ RISCV64_REG_T4, ++ RISCV64_REG_T5, ++ RISCV64_REG_T6, ++ RISCV64_REG_MAX, ++}; ++ ++} // namespace unwindstack +diff --git a/system/core/libunwindstack/include/unwindstack/RegsGetLocal.h b/system/core/libunwindstack/include/unwindstack/RegsGetLocal.h +index f0b5e3a..698eba2 100644 +--- a/system/core/libunwindstack/include/unwindstack/RegsGetLocal.h ++++ b/system/core/libunwindstack/include/unwindstack/RegsGetLocal.h +@@ -81,6 +81,49 @@ inline __attribute__((__always_inline__)) void AsmGetRegs(void* reg_data) { + : "x12", "x13", "memory"); + } + ++#elif defined(__riscv) ++ ++inline __attribute__((__always_inline__)) void AsmGetRegs(void* reg_data) { ++ asm volatile( ++ "1:\n" ++ "sd ra, 8(%[base])\n" ++ "sd sp, 16(%[base])\n" ++ "sd gp, 24(%[base])\n" ++ "sd tp, 32(%[base])\n" ++ "sd t0, 40(%[base])\n" ++ "sd t1, 48(%[base])\n" ++ "sd t2, 56(%[base])\n" ++ "sd s0, 64(%[base])\n" ++ "sd s1, 72(%[base])\n" ++ "sd a0, 80(%[base])\n" ++ "sd a1, 88(%[base])\n" ++ "sd a2, 96(%[base])\n" ++ "sd a3, 104(%[base])\n" ++ "sd a4, 112(%[base])\n" ++ "sd a5, 120(%[base])\n" ++ "sd a6, 128(%[base])\n" ++ "sd a7, 136(%[base])\n" ++ "sd s2, 144(%[base])\n" ++ "sd s3, 152(%[base])\n" ++ "sd s4, 160(%[base])\n" ++ "sd s5, 168(%[base])\n" ++ "sd s6, 176(%[base])\n" ++ "sd s7, 184(%[base])\n" ++ "sd s8, 192(%[base])\n" ++ "sd s9, 200(%[base])\n" ++ "sd s10, 208(%[base])\n" ++ "sd s11, 216(%[base])\n" ++ "sd t3, 224(%[base])\n" ++ "sd t4, 232(%[base])\n" ++ "sd t5, 240(%[base])\n" ++ "sd t6, 248(%[base])\n" ++ "la t1, 1b\n" ++ "sd t1, 0(%[base])\n" ++ : [base] "+r"(reg_data) ++ : ++ : "t1", "memory"); ++} ++ + #elif defined(__i386__) || defined(__x86_64__) || defined(__mips__) + + extern "C" void AsmGetRegs(void* regs); +diff --git a/system/core/libunwindstack/include/unwindstack/RegsRiscv64.h b/system/core/libunwindstack/include/unwindstack/RegsRiscv64.h +new file mode 100644 +index 0000000..eb09397 +--- /dev/null ++++ b/system/core/libunwindstack/include/unwindstack/RegsRiscv64.h +@@ -0,0 +1,59 @@ ++/* ++ * Copyright (C) 2022 The Android Open Source Project ++ * ++ * Licensed under the Apache License, Version 2.0 (the "License"); ++ * you may not use this file except in compliance with the License. ++ * You may obtain a copy of the License at ++ * ++ * http://www.apache.org/licenses/LICENSE-2.0 ++ * ++ * Unless required by applicable law or agreed to in writing, software ++ * distributed under the License is distributed on an "AS IS" BASIS, ++ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ++ * See the License for the specific language governing permissions and ++ * limitations under the License. ++ */ ++ ++#pragma once ++ ++#include ++ ++#include ++ ++#include ++#include ++ ++namespace unwindstack { ++ ++// Forward declarations. ++class Memory; ++ ++class RegsRiscv64 : public RegsImpl { ++ public: ++ RegsRiscv64(); ++ virtual ~RegsRiscv64() = default; ++ ++ ArchEnum Arch() override final; ++ ++ uint64_t GetPcAdjustment(uint64_t rel_pc, Elf* elf) override; ++ ++ bool SetPcFromReturnAddress(Memory* process_memory) override; ++ ++ bool StepIfSignalHandler(uint64_t elf_offset, Elf* elf, Memory* process_memory) override; ++ ++ void IterateRegisters(std::function) override final; ++ ++ uint64_t pc() override; ++ uint64_t sp() override; ++ ++ void set_pc(uint64_t pc) override; ++ void set_sp(uint64_t sp) override; ++ ++ Regs* Clone() override final; ++ ++ static Regs* Read(void* data); ++ ++ static Regs* CreateFromUcontext(void* ucontext); ++}; ++ ++} // namespace unwindstack +diff --git a/system/core/libunwindstack/include/unwindstack/UcontextRiscv64.h b/system/core/libunwindstack/include/unwindstack/UcontextRiscv64.h +new file mode 100644 +index 0000000..c6c82b1 +--- /dev/null ++++ b/system/core/libunwindstack/include/unwindstack/UcontextRiscv64.h +@@ -0,0 +1,80 @@ ++/* ++ * Copyright (C) 2014 The Android Open Source Project ++ * All rights reserved. ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * * Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * * Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in ++ * the documentation and/or other materials provided with the ++ * distribution. ++ * ++ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ++ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ++ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS ++ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ++ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, ++ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, ++ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS ++ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED ++ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, ++ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT ++ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF ++ * SUCH DAMAGE. ++ */ ++ ++#pragma once ++ ++#include ++ ++typedef uint64_t __riscv_mc_gp_state[32]; // unsigned long ++ ++struct __riscv_mc_f_ext_state { ++ uint32_t __f[32]; ++ uint32_t __fcsr; ++}; ++ ++struct __riscv_mc_d_ext_state { ++ uint64_t __f[32]; ++ uint32_t __fcsr; ++}; ++ ++struct __riscv_mc_q_ext_state { ++ uint64_t __f[64] __attribute__((__aligned__(16))); ++ uint32_t __fcsr; ++ uint32_t __reserved[3]; ++}; ++ ++union __riscv_mc_fp_state { ++ struct __riscv_mc_f_ext_state __f; ++ struct __riscv_mc_d_ext_state __d; ++ struct __riscv_mc_q_ext_state __q; ++}; ++ ++struct __riscv_stack_t { ++ uint64_t ss_sp; ++ int32_t ss_flags; ++ uint64_t ss_size; ++}; ++ ++struct riscv64_sigset_t { ++ uint64_t sig; // unsigned long ++}; ++ ++struct riscv64_mcontext_t { ++ __riscv_mc_gp_state __gregs; ++ union __riscv_mc_fp_state __fpregs; ++}; ++ ++struct riscv64_ucontext_t { ++ uint64_t uc_flags; // unsigned long ++ struct riscv64_ucontext_t* uc_link; ++ __riscv_stack_t uc_stack; ++ riscv64_sigset_t uc_sigmask; ++ /* The kernel adds extra padding here to allow sigset_t to grow. */ ++ int8_t __padding[128 - sizeof(riscv64_sigset_t)]; // char ++ riscv64_mcontext_t uc_mcontext; ++}; +diff --git a/system/core/libunwindstack/include/unwindstack/UserRiscv64.h b/system/core/libunwindstack/include/unwindstack/UserRiscv64.h +new file mode 100644 +index 0000000..1e91228 +--- /dev/null ++++ b/system/core/libunwindstack/include/unwindstack/UserRiscv64.h +@@ -0,0 +1,37 @@ ++/* ++ * Copyright (C) 2016 The Android Open Source Project ++ * All rights reserved. ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * * Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * * Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in ++ * the documentation and/or other materials provided with the ++ * distribution. ++ * ++ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ++ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ++ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS ++ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ++ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, ++ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, ++ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS ++ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED ++ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, ++ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT ++ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF ++ * SUCH DAMAGE. ++ */ ++ ++#pragma once ++ ++namespace unwindstack { ++ ++struct riscv64_user_regs { ++ uint64_t regs[32]; ++}; ++ ++} // namespace unwindstack +diff --git a/system/core/libunwindstack/tools/unwind.cpp b/system/core/libunwindstack/tools/unwind.cpp +index 1812e50..ae20891 100644 +--- a/system/core/libunwindstack/tools/unwind.cpp ++++ b/system/core/libunwindstack/tools/unwind.cpp +@@ -83,6 +83,9 @@ void DoUnwind(pid_t pid) { + case unwindstack::ARCH_MIPS64: + printf("mips64"); + break; ++ case unwindstack::ARCH_RISCV64: ++ printf("riscv64"); ++ break; + default: + printf("unknown\n"); + return; +diff --git a/system/core/libunwindstack/tools/unwind_symbols.cpp b/system/core/libunwindstack/tools/unwind_symbols.cpp +index 8df2284..976db56 100644 +--- a/system/core/libunwindstack/tools/unwind_symbols.cpp ++++ b/system/core/libunwindstack/tools/unwind_symbols.cpp +@@ -77,6 +77,9 @@ int main(int argc, char** argv) { + case EM_AARCH64: + printf("ABI: arm64\n"); + break; ++ case EM_RISCV: ++ printf("ABI: riscv64\n"); ++ break; + case EM_386: + printf("ABI: x86\n"); + break; diff --git a/meta-oe/recipes-devtools/android-tools/android-tools/debian/Added-missing-headers.patch b/meta-oe/recipes-devtools/android-tools/android-tools/debian/Added-missing-headers.patch new file mode 100644 index 0000000000..d827d7d3c2 --- /dev/null +++ b/meta-oe/recipes-devtools/android-tools/android-tools/debian/Added-missing-headers.patch @@ -0,0 +1,46 @@ +Upstream-Status: Pending + +Description: Added missing headers causing compile errors +Author: Umang Parmar +Forwarded: not-needed + +--- a/system/core/adb/sysdeps/posix/network.cpp ++++ b/system/core/adb/sysdeps/posix/network.cpp +@@ -22,6 +22,7 @@ + #include + + #include ++#include + + #include + #include +--- a/system/core/base/file.cpp ++++ b/system/core/base/file.cpp +@@ -26,6 +26,7 @@ + #include + #include + #include ++#include + + #include + #include +--- a/system/core/libbacktrace/BacktraceMap.cpp ++++ b/system/core/libbacktrace/BacktraceMap.cpp +@@ -21,6 +21,7 @@ + #include + #include + #include ++#include + + #include + +--- a/system/core/libbacktrace/UnwindStackMap.cpp ++++ b/system/core/libbacktrace/UnwindStackMap.cpp +@@ -20,6 +20,7 @@ + + #include + #include ++#include + + #include + #include diff --git a/meta-oe/recipes-devtools/android-tools/android-tools/debian/Nonnull.patch b/meta-oe/recipes-devtools/android-tools/android-tools/debian/Nonnull.patch new file mode 100644 index 0000000000..54bd52c61a --- /dev/null +++ b/meta-oe/recipes-devtools/android-tools/android-tools/debian/Nonnull.patch @@ -0,0 +1,22 @@ +Upstream-Status: Pending + +Description: Bring Clang's _Nonnull keyword to GCC +Author: Kai-Chung Yan +Forwarded: not-needed +--- a/system/core/adb/sysdeps.h ++++ b/system/core/adb/sysdeps.h +@@ -40,11 +40,12 @@ + #include "sysdeps/network.h" + #include "sysdeps/stat.h" + ++#define _Nonnull ++#define _Nullable ++ + #ifdef _WIN32 + + // Clang-only nullability specifiers +-#define _Nonnull +-#define _Nullable + + #include + #include diff --git a/meta-oe/recipes-devtools/android-tools/android-tools/debian/Vector-cast.patch b/meta-oe/recipes-devtools/android-tools/android-tools/debian/Vector-cast.patch new file mode 100644 index 0000000000..b2881e0213 --- /dev/null +++ b/meta-oe/recipes-devtools/android-tools/android-tools/debian/Vector-cast.patch @@ -0,0 +1,16 @@ +Upstream-Status: Pending + +Description: Fix the weird error by GCC7 that fails to match the correct parent method. +Author: Kai-Chung Yan +Forwarded: not-needed +--- a/system/core/libutils/include/utils/Vector.h ++++ b/system/core/libutils/include/utils/Vector.h +@@ -256,7 +256,7 @@ + + template inline + const Vector& Vector::operator = (const Vector& rhs) const { +- VectorImpl::operator = (static_cast(rhs)); ++ VectorImpl::operator = (rhs); + return *this; + } + diff --git a/meta-oe/recipes-devtools/android-tools/android-tools/debian/add-missing-headers.patch b/meta-oe/recipes-devtools/android-tools/android-tools/debian/add-missing-headers.patch new file mode 100644 index 0000000000..681d2c6553 --- /dev/null +++ b/meta-oe/recipes-devtools/android-tools/android-tools/debian/add-missing-headers.patch @@ -0,0 +1,43 @@ +Upstream-Status: Pending + +Forwarded: not-needed +--- a/system/core/fs_mgr/liblp/reader.cpp ++++ b/system/core/fs_mgr/liblp/reader.cpp +@@ -22,6 +22,7 @@ + #include + + #include ++#include + + #include + #include +--- a/system/core/fs_mgr/liblp/writer.cpp ++++ b/system/core/fs_mgr/liblp/writer.cpp +@@ -21,6 +21,7 @@ + #include + + #include ++#include + + #include + #include +--- a/system/core/liblog/logger_write.cpp ++++ b/system/core/liblog/logger_write.cpp +@@ -27,6 +27,7 @@ + #include + #endif + ++#include + #include + + #include +--- a/system/core/libziparchive/zip_archive_stream_entry.cc ++++ b/system/core/libziparchive/zip_archive_stream_entry.cc +@@ -23,6 +23,7 @@ + #include + #include + ++#include + #include + #include + diff --git a/meta-oe/recipes-devtools/android-tools/android-tools/debian/external/libunwind/20150704-CVE-2015-3239_dwarf_i.h.patch b/meta-oe/recipes-devtools/android-tools/android-tools/debian/external/libunwind/20150704-CVE-2015-3239_dwarf_i.h.patch new file mode 100644 index 0000000000..e8e216161e --- /dev/null +++ b/meta-oe/recipes-devtools/android-tools/android-tools/debian/external/libunwind/20150704-CVE-2015-3239_dwarf_i.h.patch @@ -0,0 +1,15 @@ +Upstream-Status: Pending + +Description: Off-by-one error in the dwarf_to_unw_regnum function in include/dwarf_i.h in +libunwind 1.1 allows local users to have unspecified impact via invalid dwarf opcodes. +--- a/external/libunwind/include/dwarf_i.h ++++ b/external/libunwind/include/dwarf_i.h +@@ -20,7 +20,7 @@ + extern const uint8_t dwarf_to_unw_regnum_map[DWARF_REGNUM_MAP_LENGTH]; + /* REG is evaluated multiple times; it better be side-effects free! */ + # define dwarf_to_unw_regnum(reg) \ +- (((reg) <= DWARF_REGNUM_MAP_LENGTH) ? dwarf_to_unw_regnum_map[reg] : 0) ++ (((reg) < DWARF_REGNUM_MAP_LENGTH) ? dwarf_to_unw_regnum_map[reg] : 0) + #endif + + #ifdef UNW_LOCAL_ONLY diff --git a/meta-oe/recipes-devtools/android-tools/android-tools/debian/external/libunwind/legacy_built-in_sync_functions.patch b/meta-oe/recipes-devtools/android-tools/android-tools/debian/external/libunwind/legacy_built-in_sync_functions.patch new file mode 100644 index 0000000000..a04a887c68 --- /dev/null +++ b/meta-oe/recipes-devtools/android-tools/android-tools/debian/external/libunwind/legacy_built-in_sync_functions.patch @@ -0,0 +1,28 @@ +Upstream-Status: Pending + +Description: Replace the legacy __sync built-in functions with __atomic ones + libunwind uses the built-in __sync_* functions which are deprecated by GCC and + should be replaced by __atomic_* ones. See the official manuals [1]. + . + The legacy __sync functions do not require to specify the memory order but + __atomic ones do, so we choose the strongest one: __ATOMIC_SEQ_CST. + . + We do this because __sync_fetch_and_add() is not supported on armel. + . + [1]: https://gcc.gnu.org/onlinedocs/gcc/_005f_005fsync-Builtins.html +Author: Kai-Chung Yan () +Last-Update: 2016-10-04 +Forwarded: not-needed +--- a/external/libunwind/include/libunwind_i.h ++++ b/external/libunwind/include/libunwind_i.h +@@ -155,8 +155,8 @@ cmpxchg_ptr (void *addr, void *old, void + u.vp = addr; + return __sync_bool_compare_and_swap(u.vlp, (long) old, (long) new); + } +-# define fetch_and_add1(_ptr) __sync_fetch_and_add(_ptr, 1) +-# define fetch_and_add(_ptr, value) __sync_fetch_and_add(_ptr, value) ++# define fetch_and_add1(_ptr) __atomic_fetch_add(_ptr, 1, __ATOMIC_SEQ_CST) ++# define fetch_and_add(_ptr, value) __atomic_fetch_add(_ptr, value, __ATOMIC_SEQ_CST) + # define HAVE_CMPXCHG + # define HAVE_FETCH_AND_ADD + #endif diff --git a/meta-oe/recipes-devtools/android-tools/android-tools/debian/external/libunwind/libunwind-fix-strchr-conformance-to-ISO-C23.patch b/meta-oe/recipes-devtools/android-tools/android-tools/debian/external/libunwind/libunwind-fix-strchr-conformance-to-ISO-C23.patch new file mode 100644 index 0000000000..4da65ea285 --- /dev/null +++ b/meta-oe/recipes-devtools/android-tools/android-tools/debian/external/libunwind/libunwind-fix-strchr-conformance-to-ISO-C23.patch @@ -0,0 +1,27 @@ +From d91f5324f809c3a5b0343927716e4b99bc31db53 Mon Sep 17 00:00:00 2001 +From: Viswanath Kraleti +Date: Fri, 13 Mar 2026 18:57:36 +0530 +Subject: [PATCH] libunwind: fix strchr() conformance to ISO C23 + +Fix uses of strchr() to conform to ISO C23, supported since glibc-2.43 + +Signed-off-by: Viswanath Kraleti +Upstream-Status: Pending +--- + external/libunwind/src/dwarf/Gfind_proc_info-lsb.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/external/libunwind/src/dwarf/Gfind_proc_info-lsb.c b/external/libunwind/src/dwarf/Gfind_proc_info-lsb.c +index 77ed3d09..37eadf52 100644 +--- a/external/libunwind/src/dwarf/Gfind_proc_info-lsb.c ++++ b/external/libunwind/src/dwarf/Gfind_proc_info-lsb.c +@@ -248,7 +248,8 @@ load_debug_frame (const char *file, char **buf, size_t *bufsize, + + if (*buf == NULL && linkbuf != NULL && memchr (linkbuf, 0, linksize) != NULL) + { +- char *newname, *basedir, *p; ++ char *newname, *basedir; ++ const char *p; + static const char *debugdir = "/usr/lib/debug"; + int ret; + diff --git a/meta-oe/recipes-devtools/android-tools/android-tools/debian/external/libunwind/libunwind-guard-unreachable-macro-to-avoid-redefinit.patch b/meta-oe/recipes-devtools/android-tools/android-tools/debian/external/libunwind/libunwind-guard-unreachable-macro-to-avoid-redefinit.patch new file mode 100644 index 0000000000..1e0f15ddf0 --- /dev/null +++ b/meta-oe/recipes-devtools/android-tools/android-tools/debian/external/libunwind/libunwind-guard-unreachable-macro-to-avoid-redefinit.patch @@ -0,0 +1,42 @@ +From e64495a109eefaf87235729f4dd79fc9121c16a6 Mon Sep 17 00:00:00 2001 +From: Sasi Kumar Maddineni +Date: Mon, 27 Oct 2025 19:39:05 +0530 +Subject: [PATCH] libunwind: guard unreachable() macro to avoid redefinition + with stddef.h + +The build fails due to a macro redefinition conflict for `unreachable()`. +GCC 15.2.0 defines `unreachable()` in `stddef.h`, and `libunwind_i.h` also +defines it based on the presence of `HAVE__BUILTIN_UNREACHABLE`. This causes +a redefinition error when building with `-Werror`. + +Added a guard around the `unreachable()` macro definition in `libunwind_i.h` +to ensure it is only defined if not already present. + +Upstream-Status: Pending + +Signed-off-by: Sasi Kumar Maddineni +--- + external/libunwind/include/libunwind_i.h | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/external/libunwind/include/libunwind_i.h b/external/libunwind/include/libunwind_i.h +index c06912a6..59a462df 100644 +--- a/external/libunwind/include/libunwind_i.h ++++ b/external/libunwind/include/libunwind_i.h +@@ -88,11 +88,13 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ + # endif + #endif + ++#if !defined(unreachable) + #if defined(HAVE__BUILTIN_UNREACHABLE) + # define unreachable() __builtin_unreachable() + #else + # define unreachable() do { } while (1) + #endif ++#endif + + #ifdef DEBUG + # define UNW_DEBUG 1 +-- +2.34.1 + diff --git a/meta-oe/recipes-devtools/android-tools/android-tools/debian/external/libunwind/user_pt_regs.patch b/meta-oe/recipes-devtools/android-tools/android-tools/debian/external/libunwind/user_pt_regs.patch new file mode 100644 index 0000000000..35df944d1c --- /dev/null +++ b/meta-oe/recipes-devtools/android-tools/android-tools/debian/external/libunwind/user_pt_regs.patch @@ -0,0 +1,26 @@ +Upstream-Status: Pending + +Author: Kai-Chung Yan +Last-Update: 2016-08-24 +Description: Manual definition of struct user_pt_regs + On ARM64, libunwind uses struct user_pt_regs which is not defined in + anywhere, which causes FTBFS. +Forwarded: not-needed +--- a/external/libunwind/src/ptrace/_UPT_access_reg.c ++++ b/external/libunwind/src/ptrace/_UPT_access_reg.c +@@ -26,6 +26,15 @@ WITH THE SOFTWARE OR THE USE OR OTHER DE + + #include "_UPT_internal.h" + ++#if defined(__aarch64__) ++ struct user_pt_regs { ++ __u64 regs[31]; ++ __u64 sp; ++ __u64 pc; ++ __u64 pstate; ++ }; ++#endif ++ + #if UNW_TARGET_IA64 + # include + # ifdef HAVE_ASM_PTRACE_OFFSETS_H diff --git a/meta-oe/recipes-devtools/android-tools/android-tools/debian/fix-attribute-issue-with-gcc.patch b/meta-oe/recipes-devtools/android-tools/android-tools/debian/fix-attribute-issue-with-gcc.patch new file mode 100644 index 0000000000..441031f536 --- /dev/null +++ b/meta-oe/recipes-devtools/android-tools/android-tools/debian/fix-attribute-issue-with-gcc.patch @@ -0,0 +1,19 @@ +Upstream-Status: Pending + +Description: remove clang-ism +Forwarded: not-needed + +--- a/system/core/base/include/android-base/logging.h ++++ b/system/core/base/include/android-base/logging.h +@@ -451,10 +451,7 @@ + // -Wno-user-defined-warnings to CPPFLAGS. + #pragma clang diagnostic push + #pragma clang diagnostic ignored "-Wgcc-compat" +-#define OSTREAM_STRING_POINTER_USAGE_WARNING \ +- __attribute__((diagnose_if(true, "Unexpected logging of string pointer", "warning"))) +-inline OSTREAM_STRING_POINTER_USAGE_WARNING +-std::ostream& operator<<(std::ostream& stream, const std::string* string_pointer) { ++inline std::ostream& operator<<(std::ostream& stream, const std::string* string_pointer) { + return stream << static_cast(string_pointer); + } + #pragma clang diagnostic pop diff --git a/meta-oe/recipes-devtools/android-tools/android-tools/debian/fix-build-on-non-x86.patch b/meta-oe/recipes-devtools/android-tools/android-tools/debian/fix-build-on-non-x86.patch new file mode 100644 index 0000000000..b1caa60c4a --- /dev/null +++ b/meta-oe/recipes-devtools/android-tools/android-tools/debian/fix-build-on-non-x86.patch @@ -0,0 +1,26 @@ +Upstream-Status: Pending + +Description: non-x86 arches do not have PAGE_SIZE +Forwarded: not-needed +--- a/system/core/base/cmsg.cpp ++++ b/system/core/base/cmsg.cpp +@@ -33,7 +33,8 @@ + const std::vector& fds) { + size_t cmsg_space = CMSG_SPACE(sizeof(int) * fds.size()); + size_t cmsg_len = CMSG_LEN(sizeof(int) * fds.size()); +- if (cmsg_space >= PAGE_SIZE) { ++ size_t pagesize = static_cast(sysconf(_SC_PAGE_SIZE)); ++ if (cmsg_space >= pagesize) { + errno = ENOMEM; + return -1; + } +@@ -75,7 +76,8 @@ + fds->clear(); + + size_t cmsg_space = CMSG_SPACE(sizeof(int) * max_fds); +- if (cmsg_space >= PAGE_SIZE) { ++ size_t pagesize = static_cast(sysconf(_SC_PAGE_SIZE)); ++ if (cmsg_space >= pagesize) { + errno = ENOMEM; + return -1; + } diff --git a/meta-oe/recipes-devtools/android-tools/android-tools/debian/fix-gettid-exception-declaration.patch b/meta-oe/recipes-devtools/android-tools/android-tools/debian/fix-gettid-exception-declaration.patch new file mode 100644 index 0000000000..5f24d0b4a0 --- /dev/null +++ b/meta-oe/recipes-devtools/android-tools/android-tools/debian/fix-gettid-exception-declaration.patch @@ -0,0 +1,26 @@ +Upstream-Status: Pending + +Description: get libcutils building +Forwarded: not-needed +--- a/system/core/libcutils/include/cutils/threads.h ++++ b/system/core/libcutils/include/cutils/threads.h +@@ -33,7 +33,7 @@ + // Deprecated: use android::base::GetThreadId instead, which doesn't truncate on Mac/Windows. + // + +-extern pid_t gettid(); ++extern pid_t gettid(void) __THROW; + + // + // Deprecated: use `_Thread_local` in C or `thread_local` in C++. +--- a/system/core/libcutils/threads.cpp ++++ b/system/core/libcutils/threads.cpp +@@ -33,7 +33,7 @@ + + // No definition needed for Android because we'll just pick up bionic's copy. + #ifndef __ANDROID__ +-pid_t gettid() { ++pid_t gettid(void) __THROW { + #if defined(__APPLE__) + uint64_t tid; + pthread_threadid_np(NULL, &tid); diff --git a/meta-oe/recipes-devtools/android-tools/android-tools/debian/fix-standard-namespace-errors.patch b/meta-oe/recipes-devtools/android-tools/android-tools/debian/fix-standard-namespace-errors.patch new file mode 100644 index 0000000000..4380308f13 --- /dev/null +++ b/meta-oe/recipes-devtools/android-tools/android-tools/debian/fix-standard-namespace-errors.patch @@ -0,0 +1,24 @@ +Upstream-Status: Pending + +Description: Add missing 'std::' scope identifiers. +Forwarded: not-needed +--- a/system/core/libunwindstack/include/unwindstack/DwarfMemory.h ++++ b/system/core/libunwindstack/include/unwindstack/DwarfMemory.h +@@ -29,7 +29,7 @@ + DwarfMemory(Memory* memory) : memory_(memory) {} + virtual ~DwarfMemory() = default; + +- bool ReadBytes(void* dst, size_t num_bytes); ++ bool ReadBytes(void* dst, std::size_t num_bytes); + + template + bool ReadSigned(uint64_t* value); +@@ -39,7 +39,7 @@ + bool ReadSLEB128(int64_t* value); + + template +- size_t GetEncodedSize(uint8_t encoding); ++ std::size_t GetEncodedSize(uint8_t encoding); + + bool AdjustEncodedValue(uint8_t encoding, uint64_t* value); + diff --git a/meta-oe/recipes-devtools/android-tools/android-tools/debian/hard-code-build-number.patch b/meta-oe/recipes-devtools/android-tools/android-tools/debian/hard-code-build-number.patch new file mode 100644 index 0000000000..4d7323bd2f --- /dev/null +++ b/meta-oe/recipes-devtools/android-tools/android-tools/debian/hard-code-build-number.patch @@ -0,0 +1,46 @@ +Upstream-Status: Pending + +Description: just hard code rather than deal with circular deps +Forwarded: not-needed +--- a/system/core/adb/adb.cpp ++++ b/system/core/adb/adb.cpp +@@ -44,8 +44,6 @@ + #include + #include + #include +-#include +-#include + + #include "adb_auth.h" + #include "adb_io.h" +@@ -69,7 +67,7 @@ + "Version %s-%s\n" + "Installed as %s\n", + ADB_VERSION_MAJOR, ADB_VERSION_MINOR, ADB_SERVER_VERSION, +- PLATFORM_TOOLS_VERSION, android::build::GetBuildNumber().c_str(), ++ PLATFORM_TOOLS_VERSION, "debian", + android::base::GetExecutablePath().c_str()); + } + +--- a/system/core/fastboot/fastboot.cpp ++++ b/system/core/fastboot/fastboot.cpp +@@ -59,10 +59,8 @@ + #include + #include + #include +-#include + #include + #include +-#include + #include + #include + +@@ -1680,7 +1678,7 @@ + setvbuf(stdout, nullptr, _IONBF, 0); + setvbuf(stderr, nullptr, _IONBF, 0); + } else if (name == "version") { +- fprintf(stdout, "fastboot version %s-%s\n", PLATFORM_TOOLS_VERSION, android::build::GetBuildNumber().c_str()); ++ fprintf(stdout, "fastboot version %s-%s\n", PLATFORM_TOOLS_VERSION, "debian"); + fprintf(stdout, "Installed as %s\n", android::base::GetExecutablePath().c_str()); + return 0; + #if !defined(_WIN32) diff --git a/meta-oe/recipes-devtools/android-tools/android-tools/debian/libusb-header-path.patch b/meta-oe/recipes-devtools/android-tools/android-tools/debian/libusb-header-path.patch new file mode 100644 index 0000000000..122bd70e7d --- /dev/null +++ b/meta-oe/recipes-devtools/android-tools/android-tools/debian/libusb-header-path.patch @@ -0,0 +1,18 @@ +Upstream-Status: Pending + +Description: libusb.h comes from different location +Author: Umang Parmar +Forwarded: not-needed +Last-Update: 2018-05-26 + +--- a/system/core/adb/client/usb_libusb.cpp ++++ b/system/core/adb/client/usb_libusb.cpp +@@ -30,7 +30,7 @@ + #include + #include + +-#include ++#include + + #include + #include diff --git a/meta-oe/recipes-devtools/android-tools/android-tools/debian/move-log-file-to-proper-dir.patch b/meta-oe/recipes-devtools/android-tools/android-tools/debian/move-log-file-to-proper-dir.patch new file mode 100644 index 0000000000..e8494ab433 --- /dev/null +++ b/meta-oe/recipes-devtools/android-tools/android-tools/debian/move-log-file-to-proper-dir.patch @@ -0,0 +1,20 @@ +Upstream-Status: Pending + +Description: Update log file directory. +Author: Umang Parmar +Last Updated: 2018-05-17 + +--- a/system/core/adb/adb_utils.cpp ++++ b/system/core/adb/adb_utils.cpp +@@ -339,6 +339,11 @@ + + return temp_path_utf8 + log_name; + #else ++ std::string log_dir = android::base::StringPrintf("/run/user/%u/adb.log", getuid()); ++ struct stat st = {0}; ++ if (stat(log_dir.c_str(), &st) == 0) { ++ return log_dir; ++ } + const char* tmp_dir = getenv("TMPDIR"); + if (tmp_dir == nullptr) tmp_dir = "/tmp"; + return android::base::StringPrintf("%s/adb.%u.log", tmp_dir, getuid()); diff --git a/meta-oe/recipes-devtools/android-tools/android-tools/debian/simg_dump-python3.patch b/meta-oe/recipes-devtools/android-tools/android-tools/debian/simg_dump-python3.patch new file mode 100644 index 0000000000..6664dc2aa5 --- /dev/null +++ b/meta-oe/recipes-devtools/android-tools/android-tools/debian/simg_dump-python3.patch @@ -0,0 +1,64 @@ +Description: Port simg_dump to Python 3. +Author: Antonio Russo +Forwarded: not-needed +Last-Update: 2019-01-05 +Origin: https://bugs.debian.org/945646 + +--- +Upstream-Status: Pending + +Index: android-platform-tools/system/core/libsparse/simg_dump.py +=================================================================== +--- android-platform-tools.orig/system/core/libsparse/simg_dump.py ++++ android-platform-tools/system/core/libsparse/simg_dump.py +@@ -1,4 +1,4 @@ +-#! /usr/bin/env python ++#! /usr/bin/env python3 + + # Copyright (C) 2012 The Android Open Source Project + # +@@ -14,7 +14,7 @@ + # See the License for the specific language governing permissions and + # limitations under the License. + +-from __future__ import print_function ++ + import csv + import getopt + import hashlib +@@ -47,7 +47,7 @@ def main(): + opts, args = getopt.getopt(sys.argv[1:], + "vsc:", + ["verbose", "showhash", "csvfile"]) +- except getopt.GetoptError, e: ++ except getopt.GetoptError as e: + print(e) + usage(me) + for o, a in opts: +@@ -66,7 +66,7 @@ def main(): + usage(me) + + if csvfilename: +- csvfile = open(csvfilename, "wb") ++ csvfile = open(csvfilename, "w", newline='') + csvwriter = csv.writer(csvfile) + + output = verbose or csvfilename or showhash +@@ -121,7 +121,7 @@ def main(): + "output offset", "output blocks", "type", "hash"]) + + offset = 0 +- for i in xrange(1, total_chunks + 1): ++ for i in range(1, total_chunks + 1): + header_bin = FH.read(12) + header = struct.unpack("<2H2I", header_bin) + chunk_type = header[0] +@@ -160,7 +160,7 @@ def main(): + if showhash: + h = hashlib.sha1() + data = fill_bin * (blk_sz / 4); +- for block in xrange(chunk_sz): ++ for block in range(chunk_sz): + h.update(data) + curhash = h.hexdigest() + elif chunk_type == 0xCAC3: diff --git a/meta-oe/recipes-devtools/android-tools/android-tools/debian/stdatomic.patch b/meta-oe/recipes-devtools/android-tools/android-tools/debian/stdatomic.patch new file mode 100644 index 0000000000..e11f3cc783 --- /dev/null +++ b/meta-oe/recipes-devtools/android-tools/android-tools/debian/stdatomic.patch @@ -0,0 +1,66 @@ +Upstream-Status: Pending + +Description: Fix incompatibility between and + This 2 headers combined will cause errors for both GCC and Clang. This patch + makes sure only one of them is present at any time. +Bug: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60932 +Bug: https://reviews.llvm.org/D45470 +--- a/system/core/libcutils/include/cutils/trace.h ++++ b/system/core/libcutils/include/cutils/trace.h +@@ -18,7 +18,14 @@ + #define _LIBS_CUTILS_TRACE_H + + #include ++#ifdef __cplusplus ++#include ++using std::atomic_bool; ++using std::atomic_load_explicit; ++using std::memory_order_acquire; ++#else + #include ++#endif + #include + #include + #include +--- a/system/core/libcutils/include/cutils/atomic.h ++++ b/system/core/libcutils/include/cutils/atomic.h +@@ -19,7 +19,23 @@ + + #include + #include ++#ifdef __cplusplus ++#include ++using std::atomic_compare_exchange_strong_explicit; ++using std::atomic_fetch_add_explicit; ++using std::atomic_fetch_or_explicit; ++using std::atomic_fetch_sub_explicit; ++using std::atomic_int_least32_t; ++using std::atomic_load_explicit; ++using std::atomic_store_explicit; ++using std::atomic_thread_fence; ++using std::memory_order::memory_order_acquire; ++using std::memory_order::memory_order_relaxed; ++using std::memory_order::memory_order_release; ++using std::memory_order::memory_order_seq_cst; ++#else + #include ++#endif + + #ifndef ANDROID_ATOMIC_INLINE + #define ANDROID_ATOMIC_INLINE static inline +--- a/system/core/liblog/logger.h ++++ b/system/core/liblog/logger.h +@@ -16,7 +16,13 @@ + + #pragma once + ++#ifdef __cplusplus ++#include ++using std::atomic_int; ++using std::atomic_uintptr_t; ++#else + #include ++#endif + #include + + #include diff --git a/meta-oe/recipes-devtools/android-tools/android-tools/debian/stub-out-fastdeploy.patch b/meta-oe/recipes-devtools/android-tools/android-tools/debian/stub-out-fastdeploy.patch new file mode 100644 index 0000000000..d86ef230f7 --- /dev/null +++ b/meta-oe/recipes-devtools/android-tools/android-tools/debian/stub-out-fastdeploy.patch @@ -0,0 +1,95 @@ +Upstream-Status: Pending + +Description: Defer packaging fastdeploy with adb for 29.x.x tags. +Forwarded: not-needed +--- a/system/core/adb/client/commandline.cpp ++++ b/system/core/adb/client/commandline.cpp +@@ -59,7 +59,6 @@ + #include "bugreport.h" + #include "client/file_sync_client.h" + #include "commandline.h" +-#include "fastdeploy.h" + #include "services.h" + #include "shell_protocol.h" + #include "sysdeps/chrono.h" +--- a/system/core/adb/client/adb_install.cpp ++++ b/system/core/adb/client/adb_install.cpp +@@ -35,7 +35,6 @@ + #include "adb_utils.h" + #include "client/file_sync_client.h" + #include "commandline.h" +-#include "fastdeploy.h" + + static constexpr int kFastDeployMinApi = 24; + +@@ -167,14 +166,6 @@ + } + + if (use_fastdeploy) { +- auto metadata = extract_metadata(file); +- if (metadata.has_value()) { +- // pass all but 1st (command) and last (apk path) parameters through to pm for +- // session creation +- std::vector pm_args{argv + 1, argv + argc - 1}; +- auto patchFd = install_patch(pm_args.size(), pm_args.data()); +- return stream_patch(file, std::move(metadata.value()), std::move(patchFd)); +- } + } + + struct stat sb; +@@ -267,16 +258,6 @@ + argv[last_apk] = apk_dest.c_str(); /* destination name, not source location */ + + if (use_fastdeploy) { +- auto metadata = extract_metadata(apk_file[0]); +- if (metadata.has_value()) { +- auto patchFd = apply_patch_on_device(apk_dest.c_str()); +- int status = stream_patch(apk_file[0], std::move(metadata.value()), std::move(patchFd)); +- +- result = pm_command(argc, argv); +- delete_device_file(apk_dest); +- +- return status; +- } + } + + if (do_sync_push(apk_file, apk_dest.c_str(), false)) { +@@ -292,7 +273,6 @@ + InstallMode installMode = INSTALL_DEFAULT; + bool use_fastdeploy = false; + bool is_reinstall = false; +- FastDeploy_AgentUpdateStrategy agent_update_strategy = FastDeploy_AgentUpdateDifferentVersion; + + for (int i = 1; i < argc; i++) { + if (!strcmp(argv[i], "--streaming")) { +@@ -313,13 +293,10 @@ + use_fastdeploy = false; + } else if (!strcmp(argv[i], "--force-agent")) { + processedArgIndicies.push_back(i); +- agent_update_strategy = FastDeploy_AgentUpdateAlways; + } else if (!strcmp(argv[i], "--date-check-agent")) { + processedArgIndicies.push_back(i); +- agent_update_strategy = FastDeploy_AgentUpdateNewerTimeStamp; + } else if (!strcmp(argv[i], "--version-check-agent")) { + processedArgIndicies.push_back(i); +- agent_update_strategy = FastDeploy_AgentUpdateDifferentVersion; + } + } + +@@ -331,13 +308,11 @@ + error_exit("Attempting to use streaming install on unsupported device"); + } + +- if (use_fastdeploy && get_device_api_level() < kFastDeployMinApi) { +- printf("Fast Deploy is only compatible with devices of API version %d or higher, " +- "ignoring.\n", +- kFastDeployMinApi); ++ if (use_fastdeploy) { ++ printf("Fast Deploy is unavailable in this build of adb, " ++ "ignoring.\n"); + use_fastdeploy = false; + } +- fastdeploy_set_agent_update_strategy(agent_update_strategy); + + std::vector passthrough_argv; + for (int i = 0; i < argc; i++) { diff --git a/meta-oe/recipes-devtools/android-tools/android-tools/debian/system/core/Add-riscv64-support.patch b/meta-oe/recipes-devtools/android-tools/android-tools/debian/system/core/Add-riscv64-support.patch new file mode 100644 index 0000000000..9fd0fa792c --- /dev/null +++ b/meta-oe/recipes-devtools/android-tools/android-tools/debian/system/core/Add-riscv64-support.patch @@ -0,0 +1,653 @@ +From: Guo Ren +Date: Wed, 29 Jun 2022 16:46:46 +0800 +Subject: Add riscv64 support + +This patch contains the dwarf unwind support for 64bit risc-v. + + * DwarfCfa.cpp (cfa_def_cfa_register): setup register if CFA_REG is + not setup for riscv64 + * Elf.cpp (GetRelPc): convert offset to virtual address for riscv64. + * ElfInterface.cpp (GetVirtAddrFromOffset): New for riscv64. + * RegsRiscv64.cpp (StepIfSignalHandler): Fix signal frame check. + libunwindstack/include/unwindstack/ + * ElfInterface.h (GetVirtAddrFromOffset): New for riscv64. + libunwindstack/tests/ + * DwarfCfaTest.cpp (cfa_def_cfa_register): ok for riscv64. + * RegsStepIfSignalHandlerTest.cpp (riscv64_step_if_signal_handler): Fix + testcase for riscv64 + +Test: Builds. +Test: All unit tests pass. + +Signed-off-by: Guo Ren +Signed-off-by: Lifang Xia +Signed-off-by: Mao Han +Change-Id: Ib21ddf23cc83f332af202df7bffcaceec16063e0 +--- +Upstream-Status: Pending + + system/core/libunwindstack/Android.bp | 1 + + system/core/libunwindstack/Elf.cpp | 2 + + system/core/libunwindstack/Regs.cpp | 10 ++ + system/core/libunwindstack/RegsRiscv64.cpp | 156 +++++++++++++++++++++ + .../core/libunwindstack/include/unwindstack/Elf.h | 5 + + .../include/unwindstack/MachineRiscv64.h | 59 ++++++++ + .../include/unwindstack/RegsGetLocal.h | 43 ++++++ + .../include/unwindstack/RegsRiscv64.h | 59 ++++++++ + .../include/unwindstack/UcontextRiscv64.h | 80 +++++++++++ + .../include/unwindstack/UserRiscv64.h | 37 +++++ + system/core/libunwindstack/tools/unwind.cpp | 3 + + .../core/libunwindstack/tools/unwind_symbols.cpp | 3 + + 12 files changed, 458 insertions(+) + create mode 100644 system/core/libunwindstack/RegsRiscv64.cpp + create mode 100644 system/core/libunwindstack/include/unwindstack/MachineRiscv64.h + create mode 100644 system/core/libunwindstack/include/unwindstack/RegsRiscv64.h + create mode 100644 system/core/libunwindstack/include/unwindstack/UcontextRiscv64.h + create mode 100644 system/core/libunwindstack/include/unwindstack/UserRiscv64.h + +diff --git a/system/core/libunwindstack/Android.bp b/system/core/libunwindstack/Android.bp +index 3695f72..f1f9c68 100644 +--- a/system/core/libunwindstack/Android.bp ++++ b/system/core/libunwindstack/Android.bp +@@ -70,6 +70,7 @@ cc_library { + "RegsArm64.cpp", + "RegsX86.cpp", + "RegsX86_64.cpp", ++ "RegsRiscv64.cpp", + "RegsMips.cpp", + "RegsMips64.cpp", + "Unwinder.cpp", +diff --git a/system/core/libunwindstack/Elf.cpp b/system/core/libunwindstack/Elf.cpp +index f01b092..3c2088b 100644 +--- a/system/core/libunwindstack/Elf.cpp ++++ b/system/core/libunwindstack/Elf.cpp +@@ -290,6 +290,8 @@ ElfInterface* Elf::CreateInterfaceFromMemory(Memory* memory) { + arch_ = ARCH_X86_64; + } else if (e_machine == EM_MIPS) { + arch_ = ARCH_MIPS64; ++ } else if (e_machine == EM_RISCV) { ++ arch_ = ARCH_RISCV64; + } else { + // Unsupported. + ALOGI("64 bit elf that is neither aarch64 nor x86_64 nor mips64: e_machine = %d\n", +diff --git a/system/core/libunwindstack/Regs.cpp b/system/core/libunwindstack/Regs.cpp +index c7dec52..447a554 100644 +--- a/system/core/libunwindstack/Regs.cpp ++++ b/system/core/libunwindstack/Regs.cpp +@@ -27,12 +27,14 @@ + #include + #include + #include ++#include + #include + #include + #include + #include + #include + #include ++#include + #include + #include + +@@ -67,6 +69,8 @@ Regs* Regs::RemoteGet(pid_t pid) { + return RegsMips::Read(buffer.data()); + case sizeof(mips64_user_regs): + return RegsMips64::Read(buffer.data()); ++ case sizeof(riscv64_user_regs): ++ return RegsRiscv64::Read(buffer.data()); + } + return nullptr; + } +@@ -85,6 +89,8 @@ Regs* Regs::CreateFromUcontext(ArchEnum arch, void* ucontext) { + return RegsMips::CreateFromUcontext(ucontext); + case ARCH_MIPS64: + return RegsMips64::CreateFromUcontext(ucontext); ++ case ARCH_RISCV64: ++ return RegsRiscv64::CreateFromUcontext(ucontext); + case ARCH_UNKNOWN: + default: + return nullptr; +@@ -104,6 +110,8 @@ ArchEnum Regs::CurrentArch() { + return ARCH_MIPS; + #elif defined(__mips__) && defined(__LP64__) + return ARCH_MIPS64; ++#elif defined(__riscv) ++ return ARCH_RISCV64; + #else + abort(); + #endif +@@ -123,6 +131,8 @@ Regs* Regs::CreateFromLocal() { + regs = new RegsMips(); + #elif defined(__mips__) && defined(__LP64__) + regs = new RegsMips64(); ++#elif defined(__riscv) ++ regs = new RegsRiscv64(); + #else + abort(); + #endif +diff --git a/system/core/libunwindstack/RegsRiscv64.cpp b/system/core/libunwindstack/RegsRiscv64.cpp +new file mode 100644 +index 0000000..887762a +--- /dev/null ++++ b/system/core/libunwindstack/RegsRiscv64.cpp +@@ -0,0 +1,156 @@ ++/* ++ * Copyright (C) 2022 The Android Open Source Project ++ * ++ * Licensed under the Apache License, Version 2.0 (the "License"); ++ * you may not use this file except in compliance with the License. ++ * You may obtain a copy of the License at ++ * ++ * http://www.apache.org/licenses/LICENSE-2.0 ++ * ++ * Unless required by applicable law or agreed to in writing, software ++ * distributed under the License is distributed on an "AS IS" BASIS, ++ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ++ * See the License for the specific language governing permissions and ++ * limitations under the License. ++ */ ++ ++#include ++#include ++ ++#include ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++ ++namespace unwindstack { ++ ++RegsRiscv64::RegsRiscv64() ++ : RegsImpl(RISCV64_REG_MAX, Location(LOCATION_REGISTER, RISCV64_REG_RA)) {} ++ ++ArchEnum RegsRiscv64::Arch() { ++ return ARCH_RISCV64; ++} ++ ++uint64_t RegsRiscv64::pc() { ++ return regs_[RISCV64_REG_PC]; ++} ++ ++uint64_t RegsRiscv64::sp() { ++ return regs_[RISCV64_REG_SP]; ++} ++ ++void RegsRiscv64::set_pc(uint64_t pc) { ++ regs_[RISCV64_REG_PC] = pc; ++} ++ ++void RegsRiscv64::set_sp(uint64_t sp) { ++ regs_[RISCV64_REG_SP] = sp; ++} ++ ++uint64_t RegsRiscv64::GetPcAdjustment(uint64_t rel_pc, Elf*) { ++ if (rel_pc < 8) { ++ return 0; ++ } ++ // For now, just assume no compact branches ++ return 8; ++} ++ ++bool RegsRiscv64::SetPcFromReturnAddress(Memory*) { ++ uint64_t ra = regs_[RISCV64_REG_RA]; ++ if (regs_[RISCV64_REG_PC] == ra) { ++ return false; ++ } ++ ++ regs_[RISCV64_REG_PC] = ra; ++ return true; ++} ++ ++void RegsRiscv64::IterateRegisters(std::function fn) { ++ fn("pc", regs_[RISCV64_REG_PC]); ++ fn("ra", regs_[RISCV64_REG_RA]); ++ fn("sp", regs_[RISCV64_REG_SP]); ++ fn("gp", regs_[RISCV64_REG_GP]); ++ fn("tp", regs_[RISCV64_REG_TP]); ++ fn("t0", regs_[RISCV64_REG_T0]); ++ fn("t1", regs_[RISCV64_REG_T1]); ++ fn("t2", regs_[RISCV64_REG_T2]); ++ fn("t3", regs_[RISCV64_REG_T3]); ++ fn("t4", regs_[RISCV64_REG_T4]); ++ fn("t5", regs_[RISCV64_REG_T5]); ++ fn("t6", regs_[RISCV64_REG_T6]); ++ fn("s0", regs_[RISCV64_REG_S0]); ++ fn("s1", regs_[RISCV64_REG_S1]); ++ fn("s2", regs_[RISCV64_REG_S2]); ++ fn("s3", regs_[RISCV64_REG_S3]); ++ fn("s4", regs_[RISCV64_REG_S4]); ++ fn("s5", regs_[RISCV64_REG_S5]); ++ fn("s6", regs_[RISCV64_REG_S6]); ++ fn("s7", regs_[RISCV64_REG_S7]); ++ fn("s8", regs_[RISCV64_REG_S8]); ++ fn("s9", regs_[RISCV64_REG_S9]); ++ fn("s10", regs_[RISCV64_REG_S10]); ++ fn("s11", regs_[RISCV64_REG_S11]); ++ fn("a0", regs_[RISCV64_REG_A0]); ++ fn("a1", regs_[RISCV64_REG_A1]); ++ fn("a2", regs_[RISCV64_REG_A2]); ++ fn("a3", regs_[RISCV64_REG_A3]); ++ fn("a4", regs_[RISCV64_REG_A4]); ++ fn("a5", regs_[RISCV64_REG_A5]); ++ fn("a6", regs_[RISCV64_REG_A6]); ++ fn("a7", regs_[RISCV64_REG_A7]); ++} ++ ++Regs* RegsRiscv64::Read(void* remote_data) { ++ riscv64_user_regs* user = reinterpret_cast(remote_data); ++ ++ RegsRiscv64* regs = new RegsRiscv64(); ++ memcpy(regs->RawData(), &user->regs[0], RISCV64_REG_MAX * sizeof(uint64_t)); ++ // uint64_t* reg_data = reinterpret_cast(regs->RawData()); ++ return regs; ++} ++ ++Regs* RegsRiscv64::CreateFromUcontext(void* ucontext) { ++ riscv64_ucontext_t* riscv64_ucontext = reinterpret_cast(ucontext); ++ ++ RegsRiscv64* regs = new RegsRiscv64(); ++ memcpy(regs->RawData(), &riscv64_ucontext->uc_mcontext.__gregs[0], ++ RISCV64_REG_MAX * sizeof(uint64_t)); ++ return regs; ++} ++ ++bool RegsRiscv64::StepIfSignalHandler(uint64_t elf_offset, Elf* elf, Memory* process_memory) { ++ uint64_t data; ++ Memory* elf_memory = elf->memory(); ++ // Read from elf memory since it is usually more expensive to read from ++ // process memory. ++ if (!elf_memory->ReadFully(elf_offset, &data, sizeof(data))) { ++ return false; ++ } ++ // Look for the kernel sigreturn function. ++ // __kernel_rt_sigreturn: ++ // li a7, __NR_rt_sigreturn ++ // scall ++ ++ const uint8_t li_scall[] = {0x93, 0x08, 0xb0, 0x08, 0x73, 0x00, 0x00, 0x00}; ++ if (memcmp(&data, &li_scall, 8) != 0) { ++ return false; ++ } ++ ++ // SP + sizeof(siginfo_t) + uc_mcontext offset + PC offset. ++ if (!process_memory->ReadFully(regs_[RISCV64_REG_SP] + 0x80 + 0xb0 + 0x00, regs_.data(), ++ sizeof(uint64_t) * (RISCV64_REG_MAX))) { ++ return false; ++ } ++ return true; ++} ++ ++Regs* RegsRiscv64::Clone() { ++ return new RegsRiscv64(*this); ++} ++ ++} // namespace unwindstack +diff --git a/system/core/libunwindstack/include/unwindstack/Elf.h b/system/core/libunwindstack/include/unwindstack/Elf.h +index 472ed92..88fa0ff 100644 +--- a/system/core/libunwindstack/include/unwindstack/Elf.h ++++ b/system/core/libunwindstack/include/unwindstack/Elf.h +@@ -32,6 +32,10 @@ + #define EM_AARCH64 183 + #endif + ++#if !defined(EM_RISCV) ++#define EM_RISCV 243 ++#endif ++ + namespace unwindstack { + + // Forward declaration. +@@ -46,6 +50,7 @@ enum ArchEnum : uint8_t { + ARCH_X86_64, + ARCH_MIPS, + ARCH_MIPS64, ++ ARCH_RISCV64, + }; + + class Elf { +diff --git a/system/core/libunwindstack/include/unwindstack/MachineRiscv64.h b/system/core/libunwindstack/include/unwindstack/MachineRiscv64.h +new file mode 100644 +index 0000000..397e680 +--- /dev/null ++++ b/system/core/libunwindstack/include/unwindstack/MachineRiscv64.h +@@ -0,0 +1,59 @@ ++/* ++ * Copyright (C) 2022 The Android Open Source Project ++ * ++ * Licensed under the Apache License, Version 2.0 (the "License"); ++ * you may not use this file except in compliance with the License. ++ * You may obtain a copy of the License at ++ * ++ * http://www.apache.org/licenses/LICENSE-2.0 ++ * ++ * Unless required by applicable law or agreed to in writing, software ++ * distributed under the License is distributed on an "AS IS" BASIS, ++ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ++ * See the License for the specific language governing permissions and ++ * limitations under the License. ++ */ ++ ++#pragma once ++ ++#include ++ ++namespace unwindstack { ++ ++enum Riscv64Reg : uint16_t { ++ RISCV64_REG_PC, ++ RISCV64_REG_RA, ++ RISCV64_REG_SP, ++ RISCV64_REG_GP, ++ RISCV64_REG_TP, ++ RISCV64_REG_T0, ++ RISCV64_REG_T1, ++ RISCV64_REG_T2, ++ RISCV64_REG_S0, ++ RISCV64_REG_S1, ++ RISCV64_REG_A0, ++ RISCV64_REG_A1, ++ RISCV64_REG_A2, ++ RISCV64_REG_A3, ++ RISCV64_REG_A4, ++ RISCV64_REG_A5, ++ RISCV64_REG_A6, ++ RISCV64_REG_A7, ++ RISCV64_REG_S2, ++ RISCV64_REG_S3, ++ RISCV64_REG_S4, ++ RISCV64_REG_S5, ++ RISCV64_REG_S6, ++ RISCV64_REG_S7, ++ RISCV64_REG_S8, ++ RISCV64_REG_S9, ++ RISCV64_REG_S10, ++ RISCV64_REG_S11, ++ RISCV64_REG_T3, ++ RISCV64_REG_T4, ++ RISCV64_REG_T5, ++ RISCV64_REG_T6, ++ RISCV64_REG_MAX, ++}; ++ ++} // namespace unwindstack +diff --git a/system/core/libunwindstack/include/unwindstack/RegsGetLocal.h b/system/core/libunwindstack/include/unwindstack/RegsGetLocal.h +index f0b5e3a..698eba2 100644 +--- a/system/core/libunwindstack/include/unwindstack/RegsGetLocal.h ++++ b/system/core/libunwindstack/include/unwindstack/RegsGetLocal.h +@@ -81,6 +81,49 @@ inline __attribute__((__always_inline__)) void AsmGetRegs(void* reg_data) { + : "x12", "x13", "memory"); + } + ++#elif defined(__riscv) ++ ++inline __attribute__((__always_inline__)) void AsmGetRegs(void* reg_data) { ++ asm volatile( ++ "1:\n" ++ "sd ra, 8(%[base])\n" ++ "sd sp, 16(%[base])\n" ++ "sd gp, 24(%[base])\n" ++ "sd tp, 32(%[base])\n" ++ "sd t0, 40(%[base])\n" ++ "sd t1, 48(%[base])\n" ++ "sd t2, 56(%[base])\n" ++ "sd s0, 64(%[base])\n" ++ "sd s1, 72(%[base])\n" ++ "sd a0, 80(%[base])\n" ++ "sd a1, 88(%[base])\n" ++ "sd a2, 96(%[base])\n" ++ "sd a3, 104(%[base])\n" ++ "sd a4, 112(%[base])\n" ++ "sd a5, 120(%[base])\n" ++ "sd a6, 128(%[base])\n" ++ "sd a7, 136(%[base])\n" ++ "sd s2, 144(%[base])\n" ++ "sd s3, 152(%[base])\n" ++ "sd s4, 160(%[base])\n" ++ "sd s5, 168(%[base])\n" ++ "sd s6, 176(%[base])\n" ++ "sd s7, 184(%[base])\n" ++ "sd s8, 192(%[base])\n" ++ "sd s9, 200(%[base])\n" ++ "sd s10, 208(%[base])\n" ++ "sd s11, 216(%[base])\n" ++ "sd t3, 224(%[base])\n" ++ "sd t4, 232(%[base])\n" ++ "sd t5, 240(%[base])\n" ++ "sd t6, 248(%[base])\n" ++ "la t1, 1b\n" ++ "sd t1, 0(%[base])\n" ++ : [base] "+r"(reg_data) ++ : ++ : "t1", "memory"); ++} ++ + #elif defined(__i386__) || defined(__x86_64__) || defined(__mips__) + + extern "C" void AsmGetRegs(void* regs); +diff --git a/system/core/libunwindstack/include/unwindstack/RegsRiscv64.h b/system/core/libunwindstack/include/unwindstack/RegsRiscv64.h +new file mode 100644 +index 0000000..eb09397 +--- /dev/null ++++ b/system/core/libunwindstack/include/unwindstack/RegsRiscv64.h +@@ -0,0 +1,59 @@ ++/* ++ * Copyright (C) 2022 The Android Open Source Project ++ * ++ * Licensed under the Apache License, Version 2.0 (the "License"); ++ * you may not use this file except in compliance with the License. ++ * You may obtain a copy of the License at ++ * ++ * http://www.apache.org/licenses/LICENSE-2.0 ++ * ++ * Unless required by applicable law or agreed to in writing, software ++ * distributed under the License is distributed on an "AS IS" BASIS, ++ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ++ * See the License for the specific language governing permissions and ++ * limitations under the License. ++ */ ++ ++#pragma once ++ ++#include ++ ++#include ++ ++#include ++#include ++ ++namespace unwindstack { ++ ++// Forward declarations. ++class Memory; ++ ++class RegsRiscv64 : public RegsImpl { ++ public: ++ RegsRiscv64(); ++ virtual ~RegsRiscv64() = default; ++ ++ ArchEnum Arch() override final; ++ ++ uint64_t GetPcAdjustment(uint64_t rel_pc, Elf* elf) override; ++ ++ bool SetPcFromReturnAddress(Memory* process_memory) override; ++ ++ bool StepIfSignalHandler(uint64_t elf_offset, Elf* elf, Memory* process_memory) override; ++ ++ void IterateRegisters(std::function) override final; ++ ++ uint64_t pc() override; ++ uint64_t sp() override; ++ ++ void set_pc(uint64_t pc) override; ++ void set_sp(uint64_t sp) override; ++ ++ Regs* Clone() override final; ++ ++ static Regs* Read(void* data); ++ ++ static Regs* CreateFromUcontext(void* ucontext); ++}; ++ ++} // namespace unwindstack +diff --git a/system/core/libunwindstack/include/unwindstack/UcontextRiscv64.h b/system/core/libunwindstack/include/unwindstack/UcontextRiscv64.h +new file mode 100644 +index 0000000..c6c82b1 +--- /dev/null ++++ b/system/core/libunwindstack/include/unwindstack/UcontextRiscv64.h +@@ -0,0 +1,80 @@ ++/* ++ * Copyright (C) 2014 The Android Open Source Project ++ * All rights reserved. ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * * Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * * Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in ++ * the documentation and/or other materials provided with the ++ * distribution. ++ * ++ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ++ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ++ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS ++ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ++ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, ++ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, ++ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS ++ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED ++ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, ++ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT ++ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF ++ * SUCH DAMAGE. ++ */ ++ ++#pragma once ++ ++#include ++ ++typedef uint64_t __riscv_mc_gp_state[32]; // unsigned long ++ ++struct __riscv_mc_f_ext_state { ++ uint32_t __f[32]; ++ uint32_t __fcsr; ++}; ++ ++struct __riscv_mc_d_ext_state { ++ uint64_t __f[32]; ++ uint32_t __fcsr; ++}; ++ ++struct __riscv_mc_q_ext_state { ++ uint64_t __f[64] __attribute__((__aligned__(16))); ++ uint32_t __fcsr; ++ uint32_t __reserved[3]; ++}; ++ ++union __riscv_mc_fp_state { ++ struct __riscv_mc_f_ext_state __f; ++ struct __riscv_mc_d_ext_state __d; ++ struct __riscv_mc_q_ext_state __q; ++}; ++ ++struct __riscv_stack_t { ++ uint64_t ss_sp; ++ int32_t ss_flags; ++ uint64_t ss_size; ++}; ++ ++struct riscv64_sigset_t { ++ uint64_t sig; // unsigned long ++}; ++ ++struct riscv64_mcontext_t { ++ __riscv_mc_gp_state __gregs; ++ union __riscv_mc_fp_state __fpregs; ++}; ++ ++struct riscv64_ucontext_t { ++ uint64_t uc_flags; // unsigned long ++ struct riscv64_ucontext_t* uc_link; ++ __riscv_stack_t uc_stack; ++ riscv64_sigset_t uc_sigmask; ++ /* The kernel adds extra padding here to allow sigset_t to grow. */ ++ int8_t __padding[128 - sizeof(riscv64_sigset_t)]; // char ++ riscv64_mcontext_t uc_mcontext; ++}; +diff --git a/system/core/libunwindstack/include/unwindstack/UserRiscv64.h b/system/core/libunwindstack/include/unwindstack/UserRiscv64.h +new file mode 100644 +index 0000000..1e91228 +--- /dev/null ++++ b/system/core/libunwindstack/include/unwindstack/UserRiscv64.h +@@ -0,0 +1,37 @@ ++/* ++ * Copyright (C) 2016 The Android Open Source Project ++ * All rights reserved. ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * * Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * * Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in ++ * the documentation and/or other materials provided with the ++ * distribution. ++ * ++ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ++ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ++ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS ++ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ++ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, ++ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, ++ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS ++ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED ++ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, ++ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT ++ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF ++ * SUCH DAMAGE. ++ */ ++ ++#pragma once ++ ++namespace unwindstack { ++ ++struct riscv64_user_regs { ++ uint64_t regs[32]; ++}; ++ ++} // namespace unwindstack +diff --git a/system/core/libunwindstack/tools/unwind.cpp b/system/core/libunwindstack/tools/unwind.cpp +index 1812e50..ae20891 100644 +--- a/system/core/libunwindstack/tools/unwind.cpp ++++ b/system/core/libunwindstack/tools/unwind.cpp +@@ -83,6 +83,9 @@ void DoUnwind(pid_t pid) { + case unwindstack::ARCH_MIPS64: + printf("mips64"); + break; ++ case unwindstack::ARCH_RISCV64: ++ printf("riscv64"); ++ break; + default: + printf("unknown\n"); + return; +diff --git a/system/core/libunwindstack/tools/unwind_symbols.cpp b/system/core/libunwindstack/tools/unwind_symbols.cpp +index 8df2284..976db56 100644 +--- a/system/core/libunwindstack/tools/unwind_symbols.cpp ++++ b/system/core/libunwindstack/tools/unwind_symbols.cpp +@@ -77,6 +77,9 @@ int main(int argc, char** argv) { + case EM_AARCH64: + printf("ABI: arm64\n"); + break; ++ case EM_RISCV: ++ printf("ABI: riscv64\n"); ++ break; + case EM_386: + printf("ABI: x86\n"); + break; diff --git a/meta-oe/recipes-devtools/android-tools/android-tools/debian/system/core/Added-missing-headers.patch b/meta-oe/recipes-devtools/android-tools/android-tools/debian/system/core/Added-missing-headers.patch new file mode 100644 index 0000000000..d827d7d3c2 --- /dev/null +++ b/meta-oe/recipes-devtools/android-tools/android-tools/debian/system/core/Added-missing-headers.patch @@ -0,0 +1,46 @@ +Upstream-Status: Pending + +Description: Added missing headers causing compile errors +Author: Umang Parmar +Forwarded: not-needed + +--- a/system/core/adb/sysdeps/posix/network.cpp ++++ b/system/core/adb/sysdeps/posix/network.cpp +@@ -22,6 +22,7 @@ + #include + + #include ++#include + + #include + #include +--- a/system/core/base/file.cpp ++++ b/system/core/base/file.cpp +@@ -26,6 +26,7 @@ + #include + #include + #include ++#include + + #include + #include +--- a/system/core/libbacktrace/BacktraceMap.cpp ++++ b/system/core/libbacktrace/BacktraceMap.cpp +@@ -21,6 +21,7 @@ + #include + #include + #include ++#include + + #include + +--- a/system/core/libbacktrace/UnwindStackMap.cpp ++++ b/system/core/libbacktrace/UnwindStackMap.cpp +@@ -20,6 +20,7 @@ + + #include + #include ++#include + + #include + #include diff --git a/meta-oe/recipes-devtools/android-tools/android-tools/debian/system/core/Nonnull.patch b/meta-oe/recipes-devtools/android-tools/android-tools/debian/system/core/Nonnull.patch new file mode 100644 index 0000000000..54bd52c61a --- /dev/null +++ b/meta-oe/recipes-devtools/android-tools/android-tools/debian/system/core/Nonnull.patch @@ -0,0 +1,22 @@ +Upstream-Status: Pending + +Description: Bring Clang's _Nonnull keyword to GCC +Author: Kai-Chung Yan +Forwarded: not-needed +--- a/system/core/adb/sysdeps.h ++++ b/system/core/adb/sysdeps.h +@@ -40,11 +40,12 @@ + #include "sysdeps/network.h" + #include "sysdeps/stat.h" + ++#define _Nonnull ++#define _Nullable ++ + #ifdef _WIN32 + + // Clang-only nullability specifiers +-#define _Nonnull +-#define _Nullable + + #include + #include diff --git a/meta-oe/recipes-devtools/android-tools/android-tools/debian/system/core/Vector-cast.patch b/meta-oe/recipes-devtools/android-tools/android-tools/debian/system/core/Vector-cast.patch new file mode 100644 index 0000000000..b2881e0213 --- /dev/null +++ b/meta-oe/recipes-devtools/android-tools/android-tools/debian/system/core/Vector-cast.patch @@ -0,0 +1,16 @@ +Upstream-Status: Pending + +Description: Fix the weird error by GCC7 that fails to match the correct parent method. +Author: Kai-Chung Yan +Forwarded: not-needed +--- a/system/core/libutils/include/utils/Vector.h ++++ b/system/core/libutils/include/utils/Vector.h +@@ -256,7 +256,7 @@ + + template inline + const Vector& Vector::operator = (const Vector& rhs) const { +- VectorImpl::operator = (static_cast(rhs)); ++ VectorImpl::operator = (rhs); + return *this; + } + diff --git a/meta-oe/recipes-devtools/android-tools/android-tools/debian/system/core/add-missing-headers.patch b/meta-oe/recipes-devtools/android-tools/android-tools/debian/system/core/add-missing-headers.patch new file mode 100644 index 0000000000..681d2c6553 --- /dev/null +++ b/meta-oe/recipes-devtools/android-tools/android-tools/debian/system/core/add-missing-headers.patch @@ -0,0 +1,43 @@ +Upstream-Status: Pending + +Forwarded: not-needed +--- a/system/core/fs_mgr/liblp/reader.cpp ++++ b/system/core/fs_mgr/liblp/reader.cpp +@@ -22,6 +22,7 @@ + #include + + #include ++#include + + #include + #include +--- a/system/core/fs_mgr/liblp/writer.cpp ++++ b/system/core/fs_mgr/liblp/writer.cpp +@@ -21,6 +21,7 @@ + #include + + #include ++#include + + #include + #include +--- a/system/core/liblog/logger_write.cpp ++++ b/system/core/liblog/logger_write.cpp +@@ -27,6 +27,7 @@ + #include + #endif + ++#include + #include + + #include +--- a/system/core/libziparchive/zip_archive_stream_entry.cc ++++ b/system/core/libziparchive/zip_archive_stream_entry.cc +@@ -23,6 +23,7 @@ + #include + #include + ++#include + #include + #include + diff --git a/meta-oe/recipes-devtools/android-tools/android-tools/debian/system/core/android-tools-scope-write-macro-to-prevent-conflict-.patch b/meta-oe/recipes-devtools/android-tools/android-tools/debian/system/core/android-tools-scope-write-macro-to-prevent-conflict-.patch new file mode 100644 index 0000000000..61032944d8 --- /dev/null +++ b/meta-oe/recipes-devtools/android-tools/android-tools/debian/system/core/android-tools-scope-write-macro-to-prevent-conflict-.patch @@ -0,0 +1,52 @@ +From 72b53f2d5c6e1b462a288cef3d84dd302fe603d6 Mon Sep 17 00:00:00 2001 +From: Sasi Kumar Maddineni +Date: Wed, 29 Oct 2025 11:58:20 +0530 +Subject: [PATCH] android-tools: scope 'write' macro to prevent conflict with + std::basic_ostream::write + +The build fails with a compiler error due to a macro redefinition of 'write' +to '___xxx_write'. This macro substitution interferes with the standard C++ +library's definition of std::basic_ostream::write, leading to a mismatch +between function declarations and definitions in . + +Wrap the `#undef write` and `#define write ___xxx_write` directives with +`#if defined(__ANDROID__)` to ensure they are only applied when building +for +Android. + +Upstream-Status: Pending + +Signed-off-by: Sasi Kumar Maddineni +--- + system/core/adb/sysdeps.h | 4 ++++ + 1 file changed, 4 insertions(+) + +diff --git a/system/core/adb/sysdeps.h b/system/core/adb/sysdeps.h +index a4827b8a..ff51d574 100644 +--- a/system/core/adb/sysdeps.h ++++ b/system/core/adb/sysdeps.h +@@ -127,8 +127,10 @@ static __inline__ int unix_read(borrowed_fd fd, void* buf, size_t len) { + static __inline__ int unix_write(borrowed_fd fd, const void* buf, size_t len) { + return write(fd.get(), buf, len); + } ++#if defined(__ANDROID__) + #undef write + #define write ___xxx_write ++#endif + + #undef pwrite + #define pwrite ___xxx_pwrite +@@ -463,8 +465,10 @@ static __inline__ int adb_pwrite(int fd, const void* buf, size_t len, off64_t of + #endif + } + ++#if defined(__ANDROID__) + #undef write + #define write ___xxx_write ++#endif + #undef pwrite + #define pwrite ___xxx_pwrite + +-- +2.34.1 + diff --git a/meta-oe/recipes-devtools/android-tools/android-tools/debian/system/core/fix-attribute-issue-with-gcc.patch b/meta-oe/recipes-devtools/android-tools/android-tools/debian/system/core/fix-attribute-issue-with-gcc.patch new file mode 100644 index 0000000000..441031f536 --- /dev/null +++ b/meta-oe/recipes-devtools/android-tools/android-tools/debian/system/core/fix-attribute-issue-with-gcc.patch @@ -0,0 +1,19 @@ +Upstream-Status: Pending + +Description: remove clang-ism +Forwarded: not-needed + +--- a/system/core/base/include/android-base/logging.h ++++ b/system/core/base/include/android-base/logging.h +@@ -451,10 +451,7 @@ + // -Wno-user-defined-warnings to CPPFLAGS. + #pragma clang diagnostic push + #pragma clang diagnostic ignored "-Wgcc-compat" +-#define OSTREAM_STRING_POINTER_USAGE_WARNING \ +- __attribute__((diagnose_if(true, "Unexpected logging of string pointer", "warning"))) +-inline OSTREAM_STRING_POINTER_USAGE_WARNING +-std::ostream& operator<<(std::ostream& stream, const std::string* string_pointer) { ++inline std::ostream& operator<<(std::ostream& stream, const std::string* string_pointer) { + return stream << static_cast(string_pointer); + } + #pragma clang diagnostic pop diff --git a/meta-oe/recipes-devtools/android-tools/android-tools/debian/system/core/fix-build-on-non-x86.patch b/meta-oe/recipes-devtools/android-tools/android-tools/debian/system/core/fix-build-on-non-x86.patch new file mode 100644 index 0000000000..b1caa60c4a --- /dev/null +++ b/meta-oe/recipes-devtools/android-tools/android-tools/debian/system/core/fix-build-on-non-x86.patch @@ -0,0 +1,26 @@ +Upstream-Status: Pending + +Description: non-x86 arches do not have PAGE_SIZE +Forwarded: not-needed +--- a/system/core/base/cmsg.cpp ++++ b/system/core/base/cmsg.cpp +@@ -33,7 +33,8 @@ + const std::vector& fds) { + size_t cmsg_space = CMSG_SPACE(sizeof(int) * fds.size()); + size_t cmsg_len = CMSG_LEN(sizeof(int) * fds.size()); +- if (cmsg_space >= PAGE_SIZE) { ++ size_t pagesize = static_cast(sysconf(_SC_PAGE_SIZE)); ++ if (cmsg_space >= pagesize) { + errno = ENOMEM; + return -1; + } +@@ -75,7 +76,8 @@ + fds->clear(); + + size_t cmsg_space = CMSG_SPACE(sizeof(int) * max_fds); +- if (cmsg_space >= PAGE_SIZE) { ++ size_t pagesize = static_cast(sysconf(_SC_PAGE_SIZE)); ++ if (cmsg_space >= pagesize) { + errno = ENOMEM; + return -1; + } diff --git a/meta-oe/recipes-devtools/android-tools/android-tools/debian/system/core/fix-gettid-exception-declaration.patch b/meta-oe/recipes-devtools/android-tools/android-tools/debian/system/core/fix-gettid-exception-declaration.patch new file mode 100644 index 0000000000..5f24d0b4a0 --- /dev/null +++ b/meta-oe/recipes-devtools/android-tools/android-tools/debian/system/core/fix-gettid-exception-declaration.patch @@ -0,0 +1,26 @@ +Upstream-Status: Pending + +Description: get libcutils building +Forwarded: not-needed +--- a/system/core/libcutils/include/cutils/threads.h ++++ b/system/core/libcutils/include/cutils/threads.h +@@ -33,7 +33,7 @@ + // Deprecated: use android::base::GetThreadId instead, which doesn't truncate on Mac/Windows. + // + +-extern pid_t gettid(); ++extern pid_t gettid(void) __THROW; + + // + // Deprecated: use `_Thread_local` in C or `thread_local` in C++. +--- a/system/core/libcutils/threads.cpp ++++ b/system/core/libcutils/threads.cpp +@@ -33,7 +33,7 @@ + + // No definition needed for Android because we'll just pick up bionic's copy. + #ifndef __ANDROID__ +-pid_t gettid() { ++pid_t gettid(void) __THROW { + #if defined(__APPLE__) + uint64_t tid; + pthread_threadid_np(NULL, &tid); diff --git a/meta-oe/recipes-devtools/android-tools/android-tools/debian/system/core/fix-standard-namespace-errors.patch b/meta-oe/recipes-devtools/android-tools/android-tools/debian/system/core/fix-standard-namespace-errors.patch new file mode 100644 index 0000000000..4380308f13 --- /dev/null +++ b/meta-oe/recipes-devtools/android-tools/android-tools/debian/system/core/fix-standard-namespace-errors.patch @@ -0,0 +1,24 @@ +Upstream-Status: Pending + +Description: Add missing 'std::' scope identifiers. +Forwarded: not-needed +--- a/system/core/libunwindstack/include/unwindstack/DwarfMemory.h ++++ b/system/core/libunwindstack/include/unwindstack/DwarfMemory.h +@@ -29,7 +29,7 @@ + DwarfMemory(Memory* memory) : memory_(memory) {} + virtual ~DwarfMemory() = default; + +- bool ReadBytes(void* dst, size_t num_bytes); ++ bool ReadBytes(void* dst, std::size_t num_bytes); + + template + bool ReadSigned(uint64_t* value); +@@ -39,7 +39,7 @@ + bool ReadSLEB128(int64_t* value); + + template +- size_t GetEncodedSize(uint8_t encoding); ++ std::size_t GetEncodedSize(uint8_t encoding); + + bool AdjustEncodedValue(uint8_t encoding, uint64_t* value); + diff --git a/meta-oe/recipes-devtools/android-tools/android-tools/debian/system/core/hard-code-build-number.patch b/meta-oe/recipes-devtools/android-tools/android-tools/debian/system/core/hard-code-build-number.patch new file mode 100644 index 0000000000..4d7323bd2f --- /dev/null +++ b/meta-oe/recipes-devtools/android-tools/android-tools/debian/system/core/hard-code-build-number.patch @@ -0,0 +1,46 @@ +Upstream-Status: Pending + +Description: just hard code rather than deal with circular deps +Forwarded: not-needed +--- a/system/core/adb/adb.cpp ++++ b/system/core/adb/adb.cpp +@@ -44,8 +44,6 @@ + #include + #include + #include +-#include +-#include + + #include "adb_auth.h" + #include "adb_io.h" +@@ -69,7 +67,7 @@ + "Version %s-%s\n" + "Installed as %s\n", + ADB_VERSION_MAJOR, ADB_VERSION_MINOR, ADB_SERVER_VERSION, +- PLATFORM_TOOLS_VERSION, android::build::GetBuildNumber().c_str(), ++ PLATFORM_TOOLS_VERSION, "debian", + android::base::GetExecutablePath().c_str()); + } + +--- a/system/core/fastboot/fastboot.cpp ++++ b/system/core/fastboot/fastboot.cpp +@@ -59,10 +59,8 @@ + #include + #include + #include +-#include + #include + #include +-#include + #include + #include + +@@ -1680,7 +1678,7 @@ + setvbuf(stdout, nullptr, _IONBF, 0); + setvbuf(stderr, nullptr, _IONBF, 0); + } else if (name == "version") { +- fprintf(stdout, "fastboot version %s-%s\n", PLATFORM_TOOLS_VERSION, android::build::GetBuildNumber().c_str()); ++ fprintf(stdout, "fastboot version %s-%s\n", PLATFORM_TOOLS_VERSION, "debian"); + fprintf(stdout, "Installed as %s\n", android::base::GetExecutablePath().c_str()); + return 0; + #if !defined(_WIN32) diff --git a/meta-oe/recipes-devtools/android-tools/android-tools/debian/system/core/libusb-header-path.patch b/meta-oe/recipes-devtools/android-tools/android-tools/debian/system/core/libusb-header-path.patch new file mode 100644 index 0000000000..122bd70e7d --- /dev/null +++ b/meta-oe/recipes-devtools/android-tools/android-tools/debian/system/core/libusb-header-path.patch @@ -0,0 +1,18 @@ +Upstream-Status: Pending + +Description: libusb.h comes from different location +Author: Umang Parmar +Forwarded: not-needed +Last-Update: 2018-05-26 + +--- a/system/core/adb/client/usb_libusb.cpp ++++ b/system/core/adb/client/usb_libusb.cpp +@@ -30,7 +30,7 @@ + #include + #include + +-#include ++#include + + #include + #include diff --git a/meta-oe/recipes-devtools/android-tools/android-tools/debian/system/core/libziparchive-fix-missing-fixed-width-integer-types-.patch b/meta-oe/recipes-devtools/android-tools/android-tools/debian/system/core/libziparchive-fix-missing-fixed-width-integer-types-.patch new file mode 100644 index 0000000000..0b5087f283 --- /dev/null +++ b/meta-oe/recipes-devtools/android-tools/android-tools/debian/system/core/libziparchive-fix-missing-fixed-width-integer-types-.patch @@ -0,0 +1,38 @@ +From f6874a2f7de30b6eeefb2d509b895c58b93da8f7 Mon Sep 17 00:00:00 2001 +From: Sasi Kumar Maddineni +Date: Wed, 29 Oct 2025 09:38:17 +0530 +Subject: [PATCH] libziparchive: fix missing fixed-width integer types in + zip_writer.h + +Compilation fails due to undefined types 'uint16_t' and 'uint32_t' in +zip_writer.h. These types are used in struct members but are not recognized +because the required header is not included. This results in +errors such as: + error: 'uint16_t' does not name a type + error: 'uint32_t' does not name a type + +Added '#include ' to zip_writer.h to ensure fixed-width integer +types are properly defined. + +Upstream-Status: Pending + +Signed-off-by: Sasi Kumar Maddineni +--- + system/core/libziparchive/include/ziparchive/zip_writer.h | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/system/core/libziparchive/include/ziparchive/zip_writer.h b/system/core/libziparchive/include/ziparchive/zip_writer.h +index d68683df..7a05e349 100644 +--- a/system/core/libziparchive/include/ziparchive/zip_writer.h ++++ b/system/core/libziparchive/include/ziparchive/zip_writer.h +@@ -18,6 +18,7 @@ + + #include + #include ++#include + + #include + #include +-- +2.34.1 + diff --git a/meta-oe/recipes-devtools/android-tools/android-tools/debian/system/core/move-log-file-to-proper-dir.patch b/meta-oe/recipes-devtools/android-tools/android-tools/debian/system/core/move-log-file-to-proper-dir.patch new file mode 100644 index 0000000000..e8494ab433 --- /dev/null +++ b/meta-oe/recipes-devtools/android-tools/android-tools/debian/system/core/move-log-file-to-proper-dir.patch @@ -0,0 +1,20 @@ +Upstream-Status: Pending + +Description: Update log file directory. +Author: Umang Parmar +Last Updated: 2018-05-17 + +--- a/system/core/adb/adb_utils.cpp ++++ b/system/core/adb/adb_utils.cpp +@@ -339,6 +339,11 @@ + + return temp_path_utf8 + log_name; + #else ++ std::string log_dir = android::base::StringPrintf("/run/user/%u/adb.log", getuid()); ++ struct stat st = {0}; ++ if (stat(log_dir.c_str(), &st) == 0) { ++ return log_dir; ++ } + const char* tmp_dir = getenv("TMPDIR"); + if (tmp_dir == nullptr) tmp_dir = "/tmp"; + return android::base::StringPrintf("%s/adb.%u.log", tmp_dir, getuid()); diff --git a/meta-oe/recipes-devtools/android-tools/android-tools/debian/system/core/simg_dump-python3.patch b/meta-oe/recipes-devtools/android-tools/android-tools/debian/system/core/simg_dump-python3.patch new file mode 100644 index 0000000000..6664dc2aa5 --- /dev/null +++ b/meta-oe/recipes-devtools/android-tools/android-tools/debian/system/core/simg_dump-python3.patch @@ -0,0 +1,64 @@ +Description: Port simg_dump to Python 3. +Author: Antonio Russo +Forwarded: not-needed +Last-Update: 2019-01-05 +Origin: https://bugs.debian.org/945646 + +--- +Upstream-Status: Pending + +Index: android-platform-tools/system/core/libsparse/simg_dump.py +=================================================================== +--- android-platform-tools.orig/system/core/libsparse/simg_dump.py ++++ android-platform-tools/system/core/libsparse/simg_dump.py +@@ -1,4 +1,4 @@ +-#! /usr/bin/env python ++#! /usr/bin/env python3 + + # Copyright (C) 2012 The Android Open Source Project + # +@@ -14,7 +14,7 @@ + # See the License for the specific language governing permissions and + # limitations under the License. + +-from __future__ import print_function ++ + import csv + import getopt + import hashlib +@@ -47,7 +47,7 @@ def main(): + opts, args = getopt.getopt(sys.argv[1:], + "vsc:", + ["verbose", "showhash", "csvfile"]) +- except getopt.GetoptError, e: ++ except getopt.GetoptError as e: + print(e) + usage(me) + for o, a in opts: +@@ -66,7 +66,7 @@ def main(): + usage(me) + + if csvfilename: +- csvfile = open(csvfilename, "wb") ++ csvfile = open(csvfilename, "w", newline='') + csvwriter = csv.writer(csvfile) + + output = verbose or csvfilename or showhash +@@ -121,7 +121,7 @@ def main(): + "output offset", "output blocks", "type", "hash"]) + + offset = 0 +- for i in xrange(1, total_chunks + 1): ++ for i in range(1, total_chunks + 1): + header_bin = FH.read(12) + header = struct.unpack("<2H2I", header_bin) + chunk_type = header[0] +@@ -160,7 +160,7 @@ def main(): + if showhash: + h = hashlib.sha1() + data = fill_bin * (blk_sz / 4); +- for block in xrange(chunk_sz): ++ for block in range(chunk_sz): + h.update(data) + curhash = h.hexdigest() + elif chunk_type == 0xCAC3: diff --git a/meta-oe/recipes-devtools/android-tools/android-tools/debian/system/core/stdatomic.patch b/meta-oe/recipes-devtools/android-tools/android-tools/debian/system/core/stdatomic.patch new file mode 100644 index 0000000000..e11f3cc783 --- /dev/null +++ b/meta-oe/recipes-devtools/android-tools/android-tools/debian/system/core/stdatomic.patch @@ -0,0 +1,66 @@ +Upstream-Status: Pending + +Description: Fix incompatibility between and + This 2 headers combined will cause errors for both GCC and Clang. This patch + makes sure only one of them is present at any time. +Bug: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60932 +Bug: https://reviews.llvm.org/D45470 +--- a/system/core/libcutils/include/cutils/trace.h ++++ b/system/core/libcutils/include/cutils/trace.h +@@ -18,7 +18,14 @@ + #define _LIBS_CUTILS_TRACE_H + + #include ++#ifdef __cplusplus ++#include ++using std::atomic_bool; ++using std::atomic_load_explicit; ++using std::memory_order_acquire; ++#else + #include ++#endif + #include + #include + #include +--- a/system/core/libcutils/include/cutils/atomic.h ++++ b/system/core/libcutils/include/cutils/atomic.h +@@ -19,7 +19,23 @@ + + #include + #include ++#ifdef __cplusplus ++#include ++using std::atomic_compare_exchange_strong_explicit; ++using std::atomic_fetch_add_explicit; ++using std::atomic_fetch_or_explicit; ++using std::atomic_fetch_sub_explicit; ++using std::atomic_int_least32_t; ++using std::atomic_load_explicit; ++using std::atomic_store_explicit; ++using std::atomic_thread_fence; ++using std::memory_order::memory_order_acquire; ++using std::memory_order::memory_order_relaxed; ++using std::memory_order::memory_order_release; ++using std::memory_order::memory_order_seq_cst; ++#else + #include ++#endif + + #ifndef ANDROID_ATOMIC_INLINE + #define ANDROID_ATOMIC_INLINE static inline +--- a/system/core/liblog/logger.h ++++ b/system/core/liblog/logger.h +@@ -16,7 +16,13 @@ + + #pragma once + ++#ifdef __cplusplus ++#include ++using std::atomic_int; ++using std::atomic_uintptr_t; ++#else + #include ++#endif + #include + + #include diff --git a/meta-oe/recipes-devtools/android-tools/android-tools/debian/system/core/stub-out-fastdeploy.patch b/meta-oe/recipes-devtools/android-tools/android-tools/debian/system/core/stub-out-fastdeploy.patch new file mode 100644 index 0000000000..d86ef230f7 --- /dev/null +++ b/meta-oe/recipes-devtools/android-tools/android-tools/debian/system/core/stub-out-fastdeploy.patch @@ -0,0 +1,95 @@ +Upstream-Status: Pending + +Description: Defer packaging fastdeploy with adb for 29.x.x tags. +Forwarded: not-needed +--- a/system/core/adb/client/commandline.cpp ++++ b/system/core/adb/client/commandline.cpp +@@ -59,7 +59,6 @@ + #include "bugreport.h" + #include "client/file_sync_client.h" + #include "commandline.h" +-#include "fastdeploy.h" + #include "services.h" + #include "shell_protocol.h" + #include "sysdeps/chrono.h" +--- a/system/core/adb/client/adb_install.cpp ++++ b/system/core/adb/client/adb_install.cpp +@@ -35,7 +35,6 @@ + #include "adb_utils.h" + #include "client/file_sync_client.h" + #include "commandline.h" +-#include "fastdeploy.h" + + static constexpr int kFastDeployMinApi = 24; + +@@ -167,14 +166,6 @@ + } + + if (use_fastdeploy) { +- auto metadata = extract_metadata(file); +- if (metadata.has_value()) { +- // pass all but 1st (command) and last (apk path) parameters through to pm for +- // session creation +- std::vector pm_args{argv + 1, argv + argc - 1}; +- auto patchFd = install_patch(pm_args.size(), pm_args.data()); +- return stream_patch(file, std::move(metadata.value()), std::move(patchFd)); +- } + } + + struct stat sb; +@@ -267,16 +258,6 @@ + argv[last_apk] = apk_dest.c_str(); /* destination name, not source location */ + + if (use_fastdeploy) { +- auto metadata = extract_metadata(apk_file[0]); +- if (metadata.has_value()) { +- auto patchFd = apply_patch_on_device(apk_dest.c_str()); +- int status = stream_patch(apk_file[0], std::move(metadata.value()), std::move(patchFd)); +- +- result = pm_command(argc, argv); +- delete_device_file(apk_dest); +- +- return status; +- } + } + + if (do_sync_push(apk_file, apk_dest.c_str(), false)) { +@@ -292,7 +273,6 @@ + InstallMode installMode = INSTALL_DEFAULT; + bool use_fastdeploy = false; + bool is_reinstall = false; +- FastDeploy_AgentUpdateStrategy agent_update_strategy = FastDeploy_AgentUpdateDifferentVersion; + + for (int i = 1; i < argc; i++) { + if (!strcmp(argv[i], "--streaming")) { +@@ -313,13 +293,10 @@ + use_fastdeploy = false; + } else if (!strcmp(argv[i], "--force-agent")) { + processedArgIndicies.push_back(i); +- agent_update_strategy = FastDeploy_AgentUpdateAlways; + } else if (!strcmp(argv[i], "--date-check-agent")) { + processedArgIndicies.push_back(i); +- agent_update_strategy = FastDeploy_AgentUpdateNewerTimeStamp; + } else if (!strcmp(argv[i], "--version-check-agent")) { + processedArgIndicies.push_back(i); +- agent_update_strategy = FastDeploy_AgentUpdateDifferentVersion; + } + } + +@@ -331,13 +308,11 @@ + error_exit("Attempting to use streaming install on unsupported device"); + } + +- if (use_fastdeploy && get_device_api_level() < kFastDeployMinApi) { +- printf("Fast Deploy is only compatible with devices of API version %d or higher, " +- "ignoring.\n", +- kFastDeployMinApi); ++ if (use_fastdeploy) { ++ printf("Fast Deploy is unavailable in this build of adb, " ++ "ignoring.\n"); + use_fastdeploy = false; + } +- fastdeploy_set_agent_update_strategy(agent_update_strategy); + + std::vector passthrough_argv; + for (int i = 0; i < argc; i++) { diff --git a/meta-oe/recipes-devtools/android-tools/android-tools/debian/system/core/throw-exception-on-unknown-os.patch b/meta-oe/recipes-devtools/android-tools/android-tools/debian/system/core/throw-exception-on-unknown-os.patch new file mode 100644 index 0000000000..70e732131f --- /dev/null +++ b/meta-oe/recipes-devtools/android-tools/android-tools/debian/system/core/throw-exception-on-unknown-os.patch @@ -0,0 +1,18 @@ +Upstream-Status: Pending + +Description: Turn #error into exceptions + So the library can be built on non-Linux platforms too, although can't + guarauntee its functionality regarding that piece of code. +Forwarded: not-needed +--- a/system/core/base/file.cpp ++++ b/system/core/base/file.cpp +@@ -422,7 +422,8 @@ + path[PATH_MAX - 1] = 0; + return path; + #else +-#error unknown OS ++#include ++ throw std::runtime_error(std::string("Unknown OS!")); + #endif + } + diff --git a/meta-oe/recipes-devtools/android-tools/android-tools/debian/throw-exception-on-unknown-os.patch b/meta-oe/recipes-devtools/android-tools/android-tools/debian/throw-exception-on-unknown-os.patch new file mode 100644 index 0000000000..70e732131f --- /dev/null +++ b/meta-oe/recipes-devtools/android-tools/android-tools/debian/throw-exception-on-unknown-os.patch @@ -0,0 +1,18 @@ +Upstream-Status: Pending + +Description: Turn #error into exceptions + So the library can be built on non-Linux platforms too, although can't + guarauntee its functionality regarding that piece of code. +Forwarded: not-needed +--- a/system/core/base/file.cpp ++++ b/system/core/base/file.cpp +@@ -422,7 +422,8 @@ + path[PATH_MAX - 1] = 0; + return path; + #else +-#error unknown OS ++#include ++ throw std::runtime_error(std::string("Unknown OS!")); + #endif + } + diff --git a/meta-oe/recipes-devtools/android-tools/android-tools/remount b/meta-oe/recipes-devtools/android-tools/android-tools/remount new file mode 100644 index 0000000000..751c3501ef --- /dev/null +++ b/meta-oe/recipes-devtools/android-tools/android-tools/remount @@ -0,0 +1,2 @@ +#!/bin/sh +mount -o remount,rw / diff --git a/meta-oe/recipes-devtools/android-tools/android-tools/rules_yocto.mk b/meta-oe/recipes-devtools/android-tools/android-tools/rules_yocto.mk new file mode 100644 index 0000000000..2c808d3c1e --- /dev/null +++ b/meta-oe/recipes-devtools/android-tools/android-tools/rules_yocto.mk @@ -0,0 +1 @@ +CPPFLAGS += -fPIC diff --git a/meta-oe/recipes-devtools/android-tools/android-tools_29.0.6.r14.bb b/meta-oe/recipes-devtools/android-tools/android-tools_29.0.6.r14.bb new file mode 100644 index 0000000000..3d4e95b496 --- /dev/null +++ b/meta-oe/recipes-devtools/android-tools/android-tools_29.0.6.r14.bb @@ -0,0 +1,193 @@ +DESCRIPTION = "Various utilities from Android" +SECTION = "console/utils" +LICENSE = "Apache-2.0 & GPL-2.0-only & BSD-2-Clause & BSD-3-Clause" +LIC_FILES_CHKSUM = " \ + file://${COMMON_LICENSE_DIR}/Apache-2.0;md5=89aea4e17d99a7cacdbeed46a0096b10 \ + file://${COMMON_LICENSE_DIR}/GPL-2.0-only;md5=801f80980d171dd6425610833a22dbe6 \ + file://${COMMON_LICENSE_DIR}/BSD-2-Clause;md5=cb641bc04cda31daea161b1bc15da69f \ + file://${COMMON_LICENSE_DIR}/BSD-3-Clause;md5=550794465ba0ec5312d6919e203a55f9 \ +" +DEPENDS = "libbsd libpcre zlib libcap libusb squashfs-tools 7zip libselinux googletest" + +SRCREV_core = "abfd66fafcbb691d7860df059f1df1c9b1ef29da" + +SRC_URI = " \ + git://salsa.debian.org/android-tools-team/android-platform-tools;name=core;protocol=https;branch=master \ +" + +# Patches copied from android-platform-tools/debian/patches +# and applied in the order defined by the file debian/patches/series +SRC_URI += " \ + file://debian/external/libunwind/user_pt_regs.patch \ + file://debian/external/libunwind/legacy_built-in_sync_functions.patch \ + file://debian/external/libunwind/20150704-CVE-2015-3239_dwarf_i.h.patch \ + file://debian/external/libunwind/libunwind-guard-unreachable-macro-to-avoid-redefinit.patch \ + file://debian/external/libunwind/libunwind-fix-strchr-conformance-to-ISO-C23.patch \ + \ + file://debian/system/core/move-log-file-to-proper-dir.patch \ + file://debian/system/core/Added-missing-headers.patch \ + file://debian/system/core/libusb-header-path.patch \ + file://debian/system/core/stdatomic.patch \ + file://debian/system/core/Nonnull.patch \ + file://debian/system/core/Vector-cast.patch \ + file://debian/system/core/throw-exception-on-unknown-os.patch \ + file://debian/system/core/simg_dump-python3.patch \ + file://debian/system/core/fix-attribute-issue-with-gcc.patch \ + file://debian/system/core/fix-gettid-exception-declaration.patch \ + file://debian/system/core/fix-build-on-non-x86.patch \ + file://debian/system/core/add-missing-headers.patch \ + file://debian/system/core/hard-code-build-number.patch \ + file://debian/system/core/stub-out-fastdeploy.patch \ + file://debian/system/core/fix-standard-namespace-errors.patch \ + file://debian/system/core/Add-riscv64-support.patch \ + file://debian/system/core/android-tools-scope-write-macro-to-prevent-conflict-.patch \ + file://debian/system/core/libziparchive-fix-missing-fixed-width-integer-types-.patch \ + \ +" + +# patches which don't come from debian +SRC_URI += " \ + file://rules_yocto.mk;subdir=${BB_GIT_DEFAULT_DESTSUFFIX} \ + file://android-tools-adbd.service \ + file://adbd.mk;subdir=${BB_GIT_DEFAULT_DESTSUFFIX}/debian/system/core \ + file://remount \ + file://0001-Fixes-for-yocto-build.patch \ + file://0002-android-tools-modifications-to-make-it-build-in-yoct.patch \ + file://0003-Update-usage-of-usbdevfs_urb-to-match-new-kernel-UAP.patch \ + file://0004-adb-Fix-build-on-big-endian-systems.patch \ + file://0005-adb-Allow-adbd-to-be-run-as-root.patch \ + file://0001-liblp-fix-building-with-GCC-14.patch \ +" + +B = "${WORKDIR}/${BPN}" + +# http://errors.yoctoproject.org/Errors/Details/1debian881/ +ARM_INSTRUCTION_SET:armv4 = "arm" +ARM_INSTRUCTION_SET:armv5 = "arm" + +COMPATIBLE_HOST:powerpc = "(null)" +COMPATIBLE_HOST:powerpc64 = "(null)" +COMPATIBLE_HOST:powerpc64le = "(null)" + +inherit systemd + +SYSTEMD_PACKAGES = "${PN}-adbd" +SYSTEMD_SERVICE:${PN}-adbd = "android-tools-adbd.service" + +# Find libbsd headers during native builds +CC:append:class-native = " -I${STAGING_INCDIR}" +CC:append:class-nativesdk = " -I${STAGING_INCDIR}" + +PREREQUISITE_core = "liblog libbase libsparse liblog libcutils" +TOOLS_TO_BUILD = "libcrypto_utils libadb libziparchive fastboot adb img2simg simg2img libbacktrace" +TOOLS_TO_BUILD:append:class-target = " adbd" + +do_compile() { + + case "${HOST_ARCH}" in + arm) + export android_arch=linux-arm + cpu=arm + deb_host_arch=arm + ;; + aarch64) + export android_arch=linux-arm64 + cpu=arm64 + deb_host_arch=arm64 + ;; + riscv64) + export android_arch=linux-riscv64 + ;; + mips|mipsel) + export android_arch=linux-mips + cpu=mips + deb_host_arch=mips + ;; + mips64|mips64el) + export android_arch=linux-mips64 + cpu=mips64 + deb_host_arch=mips64 + ;; + powerpc|powerpc64) + export android_arch=linux-ppc + ;; + i586|i686|x86_64) + export android_arch=linux-x86 + cpu=x86_64 + deb_host_arch=amd64 + ;; + esac + + export SRCDIR=${S} + + oe_runmake -f ${S}/debian/external/boringssl/libcrypto.mk -C ${S} + oe_runmake -f ${S}/debian/external/libunwind/libunwind.mk -C ${S} CPU=${cpu} + + for tool in ${PREREQUISITE_core}; do + oe_runmake -f ${S}/debian/system/core/${tool}.mk -C ${S} + done + + for i in `find ${S}/debian/system/extras/ -name "*.mk"`; do + oe_runmake -f $i -C ${S} + done + + for tool in ${TOOLS_TO_BUILD}; do + if [ "$tool" = "libbacktrace" ]; then + oe_runmake -f ${S}/debian/system/core/${tool}.mk -C ${S} DEB_HOST_ARCH=${deb_host_arch} + else + oe_runmake -f ${S}/debian/system/core/${tool}.mk -C ${S} + fi + done + +} + +do_install() { + install -d ${D}${base_sbindir} + install -m 0755 ${UNPACKDIR}/remount -D ${D}${base_sbindir}/remount + + for tool in img2simg simg2img fastboot adbd; do + if echo ${TOOLS_TO_BUILD} | grep -q "$tool" ; then + install -D -p -m0755 ${S}/debian/out/system/core/$tool ${D}${bindir}/$tool + fi + done + + # grep adb also matches adbd, so handle adb separately from other tools + if echo ${TOOLS_TO_BUILD} | grep -q "adb " ; then + install -d ${D}${bindir} + install -m0755 ${S}/debian/out/system/core/adb ${D}${bindir} + fi + + # Outside the if statement to avoid errors during do_package + install -D -p -m0644 ${UNPACKDIR}/android-tools-adbd.service \ + ${D}${systemd_unitdir}/system/android-tools-adbd.service + + install -d ${D}${libdir}/android/ + install -m0755 ${S}/debian/out/system/core/*.so.* ${D}${libdir}/android/ + if echo ${TOOLS_TO_BUILD} | grep -q "mkbootimg" ; then + install -d ${D}${bindir} + install -m0755 ${B}/mkbootimg/mkbootimg ${D}${bindir} + fi +} + +PACKAGES =+ "${PN}-fstools ${PN}-adbd" + +RDEPENDS:${BPN} = "${BPN}-conf 7zip" + +FILES:${PN}-adbd = "\ + ${bindir}/adbd \ + ${systemd_unitdir}/system/android-tools-adbd.service \ +" + +FILES:${PN}-fstools = "\ + ${bindir}/ext2simg \ + ${bindir}/ext4fixup \ + ${bindir}/img2simg \ + ${bindir}/make_ext4fs \ + ${bindir}/simg2img \ + ${bindir}/simg2simg \ + ${bindir}/simg_dump \ + ${bindir}/mkuserimg \ +" +FILES:${PN} += "${libdir}/android ${libdir}/android/*" + +BBCLASSEXTEND = "native" -- cgit v1.2.3-54-g00ecf