diff options
Diffstat (limited to 'meta-oe/recipes-devtools/android-tools')
52 files changed, 3831 insertions, 0 deletions
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 @@ | |||
| 1 | #!/bin/sh | ||
| 2 | |||
| 3 | [ ! -e /dev/pts ] && mkdir -p /dev/pts | ||
| 4 | [ ! -e /dev/pts/0 ] && mount devpts /dev/pts -t devpts | ||
| 5 | |||
| 6 | # TODO enable the lines below once we have support for getprop | ||
| 7 | # retrieve the product info from Android | ||
| 8 | # manufacturer=$(getprop ro.product.manufacturer Android) | ||
| 9 | # model=$(getprop ro.product.model Android) | ||
| 10 | # serial=$(getprop ro.serialno 0123456789ABCDEF) | ||
| 11 | |||
| 12 | #below are now needed in order to use FunctionFS for ADB, tested to work with 3.4+ kernels | ||
| 13 | if grep -q functionfs /proc/filesystems; then | ||
| 14 | mkdir -p /dev/usb-ffs/adb | ||
| 15 | mount -t functionfs adb /dev/usb-ffs/adb | ||
| 16 | #android-gadget-setup doesn't provide below 2 and without them it won't work, so we provide them here. | ||
| 17 | echo adb > /sys/class/android_usb/android0/f_ffs/aliases | ||
| 18 | echo ffs > /sys/class/android_usb/android0/functions | ||
| 19 | fi | ||
| 20 | |||
| 21 | manufacturer="$(cat /system/build.prop | grep -o 'ro.product.manufacturer=.*' | cut -d'=' -f 2)" | ||
| 22 | model="$(cat /system/build.prop | grep -o 'ro.product.model=.*' | cut -d'=' -f 2)" | ||
| 23 | # get the device serial number from /proc/cmdline directly(since we have no getprop on | ||
| 24 | # GNU/Linux) | ||
| 25 | serial="$(cat /proc/cmdline | sed 's/.*androidboot.serialno=//' | sed 's/ .*//')" | ||
| 26 | |||
| 27 | echo $serial > /sys/class/android_usb/android0/iSerial | ||
| 28 | echo $manufacturer > /sys/class/android_usb/android0/iManufacturer | ||
| 29 | echo $model > /sys/class/android_usb/android0/iProduct | ||
| 30 | |||
| 31 | echo "0" > /sys/class/android_usb/android0/enable | ||
| 32 | echo "18d1" > /sys/class/android_usb/android0/idVendor | ||
| 33 | echo "D002" > /sys/class/android_usb/android0/idProduct | ||
| 34 | echo "adb" > /sys/class/android_usb/android0/functions | ||
| 35 | echo "1" > /sys/class/android_usb/android0/enable | ||
| 36 | |||
| 37 | 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 @@ | |||
| 1 | DESCRIPTION = "Different utilities from Android - corresponding configuration files" | ||
| 2 | SECTION = "console/utils" | ||
| 3 | LICENSE = "MIT" | ||
| 4 | LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302" | ||
| 5 | |||
| 6 | SRC_URI = "file://android-gadget-setup" | ||
| 7 | |||
| 8 | S = "${UNPACKDIR}" | ||
| 9 | |||
| 10 | do_install() { | ||
| 11 | install -d ${D}${bindir} | ||
| 12 | install -m 0755 ${UNPACKDIR}/android-gadget-setup ${D}${bindir} | ||
| 13 | } | ||
| 14 | |||
| 15 | python () { | ||
| 16 | pn = d.getVar('PN') | ||
| 17 | profprov = d.getVar("PREFERRED_PROVIDER_" + pn) | ||
| 18 | if profprov and pn != profprov: | ||
| 19 | raise bb.parse.SkipRecipe("PREFERRED_PROVIDER_%s set to %s, not %s" % (pn, profprov, pn)) | ||
| 20 | } | ||
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 @@ | |||
| 1 | From 5de85f8273c7284aa93e35c40f025d4d43d42df9 Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Etienne Cordonnier <ecordonnier@snap.com> | ||
| 3 | Date: Thu, 16 Mar 2023 18:59:35 +0100 | ||
| 4 | Subject: [PATCH] Fixes for yocto build | ||
| 5 | |||
| 6 | Signed-off-by: JJ Robertson <jrobertson@snapchat.com> | ||
| 7 | [rebased on version 29] | ||
| 8 | Signed-off-by: Etienne Cordonnier <ecordonnier@snap.com> | ||
| 9 | |||
| 10 | --- | ||
| 11 | Upstream-Status: Pending | ||
| 12 | |||
| 13 | system/core/adb/daemon/file_sync_service.cpp | 4 ++-- | ||
| 14 | system/core/adb/daemon/framebuffer_service.h | 2 -- | ||
| 15 | system/core/adb/daemon/main.cpp | 5 +++-- | ||
| 16 | system/core/adb/daemon/restart_service.h | 2 -- | ||
| 17 | system/core/adb/daemon/services.cpp | 6 ++---- | ||
| 18 | system/core/adb/daemon/shell_service.cpp | 5 ++++- | ||
| 19 | system/core/adb/types.h | 1 + | ||
| 20 | 7 files changed, 12 insertions(+), 13 deletions(-) | ||
| 21 | |||
| 22 | diff --git a/system/core/adb/daemon/file_sync_service.cpp b/system/core/adb/daemon/file_sync_service.cpp | ||
| 23 | index d6af7087..92e7087a 100644 | ||
| 24 | --- a/system/core/adb/daemon/file_sync_service.cpp | ||
| 25 | +++ b/system/core/adb/daemon/file_sync_service.cpp | ||
| 26 | @@ -111,7 +111,7 @@ static bool secure_mkdirs(const std::string& path) { | ||
| 27 | partial_path += path_component; | ||
| 28 | |||
| 29 | if (should_use_fs_config(partial_path)) { | ||
| 30 | - fs_config(partial_path.c_str(), 1, nullptr, &uid, &gid, &mode, &capabilities); | ||
| 31 | + // fs_config(partial_path.c_str(), 1, nullptr, &uid, &gid, &mode, &capabilities); | ||
| 32 | } | ||
| 33 | if (adb_mkdir(partial_path.c_str(), mode) == -1) { | ||
| 34 | if (errno != EEXIST) { | ||
| 35 | @@ -469,7 +469,7 @@ static bool do_send(int s, const std::string& spec, std::vector<char>& buffer) { | ||
| 36 | uint64_t capabilities = 0; | ||
| 37 | if (should_use_fs_config(path)) { | ||
| 38 | unsigned int broken_api_hack = mode; | ||
| 39 | - fs_config(path.c_str(), 0, nullptr, &uid, &gid, &broken_api_hack, &capabilities); | ||
| 40 | + // fs_config(path.c_str(), 0, nullptr, &uid, &gid, &broken_api_hack, &capabilities); | ||
| 41 | mode = broken_api_hack; | ||
| 42 | } | ||
| 43 | |||
| 44 | diff --git a/system/core/adb/daemon/framebuffer_service.h b/system/core/adb/daemon/framebuffer_service.h | ||
| 45 | index bab44be3..264da597 100644 | ||
| 46 | --- a/system/core/adb/daemon/framebuffer_service.h | ||
| 47 | +++ b/system/core/adb/daemon/framebuffer_service.h | ||
| 48 | @@ -18,6 +18,4 @@ | ||
| 49 | |||
| 50 | #include "adb_unique_fd.h" | ||
| 51 | |||
| 52 | -#if defined(__ANDROID__) | ||
| 53 | void framebuffer_service(unique_fd fd); | ||
| 54 | -#endif | ||
| 55 | diff --git a/system/core/adb/daemon/main.cpp b/system/core/adb/daemon/main.cpp | ||
| 56 | index 3322574c..e807d13d 100644 | ||
| 57 | --- a/system/core/adb/daemon/main.cpp | ||
| 58 | +++ b/system/core/adb/daemon/main.cpp | ||
| 59 | @@ -208,6 +208,9 @@ int adbd_main(int server_port) { | ||
| 60 | umask(0); | ||
| 61 | |||
| 62 | signal(SIGPIPE, SIG_IGN); | ||
| 63 | + signal(SIGINT, SIG_DFL); | ||
| 64 | + signal(SIGQUIT, SIG_DFL); | ||
| 65 | + | ||
| 66 | |||
| 67 | #if defined(__BIONIC__) | ||
| 68 | auto fdsan_level = android_fdsan_get_error_level(); | ||
| 69 | @@ -254,13 +257,11 @@ int adbd_main(int server_port) { | ||
| 70 | |||
| 71 | bool is_usb = false; | ||
| 72 | |||
| 73 | -#if defined(__ANDROID__) | ||
| 74 | if (access(USB_FFS_ADB_EP0, F_OK) == 0) { | ||
| 75 | // Listen on USB. | ||
| 76 | usb_init(); | ||
| 77 | is_usb = true; | ||
| 78 | } | ||
| 79 | -#endif | ||
| 80 | |||
| 81 | // If one of these properties is set, also listen on that port. | ||
| 82 | // If one of the properties isn't set and we couldn't listen on usb, listen | ||
| 83 | diff --git a/system/core/adb/daemon/restart_service.h b/system/core/adb/daemon/restart_service.h | ||
| 84 | index 19840bd5..7a97614b 100644 | ||
| 85 | --- a/system/core/adb/daemon/restart_service.h | ||
| 86 | +++ b/system/core/adb/daemon/restart_service.h | ||
| 87 | @@ -18,9 +18,7 @@ | ||
| 88 | |||
| 89 | #include "adb_unique_fd.h" | ||
| 90 | |||
| 91 | -#if defined(__ANDROID__) | ||
| 92 | void restart_root_service(unique_fd fd); | ||
| 93 | void restart_unroot_service(unique_fd fd); | ||
| 94 | void restart_tcp_service(unique_fd fd, int port); | ||
| 95 | void restart_usb_service(unique_fd fd); | ||
| 96 | -#endif | ||
| 97 | diff --git a/system/core/adb/daemon/services.cpp b/system/core/adb/daemon/services.cpp | ||
| 98 | index 4ec90d27..d8541c23 100644 | ||
| 99 | --- a/system/core/adb/daemon/services.cpp | ||
| 100 | +++ b/system/core/adb/daemon/services.cpp | ||
| 101 | @@ -156,7 +156,7 @@ static void spin_service(unique_fd fd) { | ||
| 102 | } | ||
| 103 | #endif | ||
| 104 | // Fall through | ||
| 105 | - std::string cmd = "/system/bin/reboot "; | ||
| 106 | + std::string cmd = "/sbin/reboot "; | ||
| 107 | cmd += name; | ||
| 108 | return StartSubprocess(cmd, nullptr, SubprocessType::kRaw, SubprocessProtocol::kNone); | ||
| 109 | } | ||
| 110 | @@ -265,11 +265,10 @@ unique_fd daemon_service_to_fd(std::string_view name, atransport* transport) { | ||
| 111 | } | ||
| 112 | #endif | ||
| 113 | |||
| 114 | -#if defined(__ANDROID__) | ||
| 115 | if (name.starts_with("framebuffer:")) { | ||
| 116 | return create_service_thread("fb", framebuffer_service); | ||
| 117 | } else if (android::base::ConsumePrefix(&name, "remount:")) { | ||
| 118 | - std::string cmd = "/system/bin/remount "; | ||
| 119 | + std::string cmd = "/sbin/remount "; | ||
| 120 | cmd += name; | ||
| 121 | return StartSubprocess(cmd, nullptr, SubprocessType::kRaw, SubprocessProtocol::kNone); | ||
| 122 | } else if (android::base::ConsumePrefix(&name, "reboot:")) { | ||
| 123 | @@ -303,7 +302,6 @@ unique_fd daemon_service_to_fd(std::string_view name, atransport* transport) { | ||
| 124 | } else if (name.starts_with("usb:")) { | ||
| 125 | return create_service_thread("usb", restart_usb_service); | ||
| 126 | } | ||
| 127 | -#endif | ||
| 128 | |||
| 129 | if (android::base::ConsumePrefix(&name, "dev:")) { | ||
| 130 | return unique_fd{unix_open(name, O_RDWR | O_CLOEXEC)}; | ||
| 131 | diff --git a/system/core/adb/daemon/shell_service.cpp b/system/core/adb/daemon/shell_service.cpp | ||
| 132 | index f62032d0..ebcfe18d 100644 | ||
| 133 | --- a/system/core/adb/daemon/shell_service.cpp | ||
| 134 | +++ b/system/core/adb/daemon/shell_service.cpp | ||
| 135 | @@ -273,13 +273,16 @@ bool Subprocess::ForkAndExec(std::string* error) { | ||
| 136 | env["HOSTNAME"] = GetHostName(); | ||
| 137 | env["LOGNAME"] = pw->pw_name; | ||
| 138 | env["SHELL"] = pw->pw_shell; | ||
| 139 | - env["TMPDIR"] = "/data/local/tmp"; | ||
| 140 | env["USER"] = pw->pw_name; | ||
| 141 | } | ||
| 142 | |||
| 143 | if (!terminal_type_.empty()) { | ||
| 144 | env["TERM"] = terminal_type_; | ||
| 145 | } | ||
| 146 | + if (env.find("PS1") == env.end()) { | ||
| 147 | + env["PS1"] = "\\h:\\w\\$ "; | ||
| 148 | + } | ||
| 149 | + | ||
| 150 | |||
| 151 | std::vector<std::string> joined_env; | ||
| 152 | for (const auto& it : env) { | ||
| 153 | diff --git a/system/core/adb/types.h b/system/core/adb/types.h | ||
| 154 | index c619fffc..f8e0f521 100644 | ||
| 155 | --- a/system/core/adb/types.h | ||
| 156 | +++ b/system/core/adb/types.h | ||
| 157 | @@ -22,6 +22,7 @@ | ||
| 158 | #include <memory> | ||
| 159 | #include <utility> | ||
| 160 | #include <vector> | ||
| 161 | +#include <string.h> | ||
| 162 | |||
| 163 | #include <android-base/logging.h> | ||
| 164 | |||
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 @@ | |||
| 1 | From 9f4d839847666019cadf57aa34fd366801c11a44 Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Dmitry Baryshkov <dmitry.baryshkov@linaro.org> | ||
| 3 | Date: Fri, 24 May 2024 14:13:35 +0300 | ||
| 4 | Subject: [PATCH] liblp: fix building with GCC 14 | ||
| 5 | |||
| 6 | Upstream-Status: Pending | ||
| 7 | Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org> | ||
| 8 | --- | ||
| 9 | system/core/fs_mgr/liblp/utility.cpp | 1 + | ||
| 10 | 1 file changed, 1 insertion(+) | ||
| 11 | |||
| 12 | diff --git a/system/core/fs_mgr/liblp/utility.cpp b/system/core/fs_mgr/liblp/utility.cpp | ||
| 13 | index 48c5c8318d99..0aa8023aa87d 100644 | ||
| 14 | --- a/system/core/fs_mgr/liblp/utility.cpp | ||
| 15 | +++ b/system/core/fs_mgr/liblp/utility.cpp | ||
| 16 | @@ -24,6 +24,7 @@ | ||
| 17 | #include <sys/ioctl.h> | ||
| 18 | #endif | ||
| 19 | |||
| 20 | +#include <algorithm> | ||
| 21 | #include <map> | ||
| 22 | #include <string> | ||
| 23 | #include <vector> | ||
| 24 | -- | ||
| 25 | 2.39.2 | ||
| 26 | |||
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 @@ | |||
| 1 | From 194513bababa9707ec54bc7119613a0d5eca9f79 Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Etienne Cordonnier <ecordonnier@snap.com> | ||
| 3 | Date: Fri, 17 Mar 2023 10:33:11 +0100 | ||
| 4 | Subject: [PATCH] android-tools: modifications to make it build in yocto | ||
| 5 | |||
| 6 | - Fix relocation errors on aarch64, e.g.: | ||
| 7 | "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" | ||
| 8 | |||
| 9 | - use ln -f to avoid error "File exists" on incremental builds | ||
| 10 | |||
| 11 | - fix missing headers | ||
| 12 | |||
| 13 | Signed-off-by: Etienne Cordonnier <ecordonnier@snap.com> | ||
| 14 | |||
| 15 | - fix warning: library search path "/usr/lib/p7zip" is unsafe for cross-compilation | ||
| 16 | |||
| 17 | - fix error: include location "/usr/include/android" is unsafe for cross-compilation | ||
| 18 | |||
| 19 | Upstream-Status: Pending | ||
| 20 | Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com> | ||
| 21 | --- | ||
| 22 | debian/development/etc1tool.mk | 1 - | ||
| 23 | debian/external/boringssl/libcrypto.mk | 1 + | ||
| 24 | debian/libnativehelper/libnativehelper.mk | 1 - | ||
| 25 | debian/system/core/adb.mk | 1 - | ||
| 26 | debian/system/core/append2simg.mk | 2 +- | ||
| 27 | debian/system/core/fastboot.mk | 3 +-- | ||
| 28 | debian/system/core/img2simg.mk | 2 +- | ||
| 29 | debian/system/core/libbacktrace.mk | 10 ++++------ | ||
| 30 | debian/system/core/libbase.mk | 5 +++-- | ||
| 31 | debian/system/core/libcutils.mk | 5 +++-- | ||
| 32 | debian/system/core/liblog.mk | 3 ++- | ||
| 33 | debian/system/core/libsparse.mk | 5 +++-- | ||
| 34 | debian/system/core/libutils.mk | 4 ++-- | ||
| 35 | debian/system/core/libziparchive.mk | 5 +++-- | ||
| 36 | debian/system/core/simg2img.mk | 2 +- | ||
| 37 | debian/system/core/simg2simg.mk | 2 +- | ||
| 38 | debian/system/extras/libext4_utils.mk | 1 - | ||
| 39 | frameworks/native/libs/adbd_auth/adbd_auth.cpp | 2 ++ | ||
| 40 | system/core/adb/adb_listeners.cpp | 12 ++++++------ | ||
| 41 | system/core/adb/transport_local.cpp | 2 +- | ||
| 42 | 20 files changed, 35 insertions(+), 34 deletions(-) | ||
| 43 | |||
| 44 | diff --git a/debian/development/etc1tool.mk b/debian/development/etc1tool.mk | ||
| 45 | index 2d787e98bb86..e03ac5f0048c 100644 | ||
| 46 | --- a/debian/development/etc1tool.mk | ||
| 47 | +++ b/debian/development/etc1tool.mk | ||
| 48 | @@ -4,7 +4,6 @@ SOURCES = development/tools/etc1tool/etc1tool.cpp | ||
| 49 | |||
| 50 | CXXFLAGS += -std=gnu++2a | ||
| 51 | CPPFLAGS += \ | ||
| 52 | - -I/usr/include/android \ | ||
| 53 | -Idevelopment/include \ | ||
| 54 | -Iframeworks/native/opengl/include \ | ||
| 55 | |||
| 56 | diff --git a/debian/external/boringssl/libcrypto.mk b/debian/external/boringssl/libcrypto.mk | ||
| 57 | index c0ea54f4..b3a77bfd 100644 | ||
| 58 | --- a/debian/external/boringssl/libcrypto.mk | ||
| 59 | +++ b/debian/external/boringssl/libcrypto.mk | ||
| 60 | @@ -27,6 +27,7 @@ CPPFLAGS += \ | ||
| 61 | -DBORINGSSL_IMPLEMENTATION \ | ||
| 62 | -DBORINGSSL_SHARED_LIBRARY \ | ||
| 63 | -DOPENSSL_SMALL \ | ||
| 64 | + -DOPENSSL_NO_ASM \ | ||
| 65 | -Iexternal/boringssl/src/crypto \ | ||
| 66 | -Iexternal/boringssl/src/include \ | ||
| 67 | |||
| 68 | diff --git a/debian/libnativehelper/libnativehelper.mk b/debian/libnativehelper/libnativehelper.mk | ||
| 69 | index 7a0c94a6b7b5..880b2fdf9154 100644 | ||
| 70 | --- a/debian/libnativehelper/libnativehelper.mk | ||
| 71 | +++ b/debian/libnativehelper/libnativehelper.mk | ||
| 72 | @@ -11,7 +11,6 @@ OBJECTS = $(SOURCES:.cpp=.o) | ||
| 73 | |||
| 74 | CXXFLAGS += -std=gnu++2a | ||
| 75 | CPPFLAGS += \ | ||
| 76 | - -I/usr/include/android \ | ||
| 77 | -Ilibnativehelper/header_only_include \ | ||
| 78 | -Ilibnativehelper/include \ | ||
| 79 | -Ilibnativehelper/include_jni \ | ||
| 80 | diff --git a/debian/system/core/adb.mk b/debian/system/core/adb.mk | ||
| 81 | index 9769b68ab793..58c9a63bd225 100644 | ||
| 82 | --- a/debian/system/core/adb.mk | ||
| 83 | +++ b/debian/system/core/adb.mk | ||
| 84 | @@ -19,7 +19,6 @@ CPPFLAGS += \ | ||
| 85 | -D_GNU_SOURCE \ | ||
| 86 | -DADB_HOST=1 \ | ||
| 87 | -DADB_VERSION='"$(DEB_VERSION)"' \ | ||
| 88 | - -I/usr/include/android \ | ||
| 89 | -Iexternal/boringssl/include \ | ||
| 90 | -Isystem/core/adb \ | ||
| 91 | -Isystem/core/base/include \ | ||
| 92 | @@ -28,7 +27,6 @@ CPPFLAGS += \ | ||
| 93 | LDFLAGS += \ | ||
| 94 | -Ldebian/out/system/core \ | ||
| 95 | -Wl,-rpath=/usr/lib/$(DEB_HOST_MULTIARCH)/android \ | ||
| 96 | - -fuse-ld=gold \ | ||
| 97 | -lbase \ | ||
| 98 | -lcutils \ | ||
| 99 | -lpthread \ | ||
| 100 | diff --git a/debian/system/core/append2simg.mk b/debian/system/core/append2simg.mk | ||
| 101 | index 1599bdb8..598c751d 100644 | ||
| 102 | --- a/debian/system/core/append2simg.mk | ||
| 103 | +++ b/debian/system/core/append2simg.mk | ||
| 104 | @@ -11,7 +11,7 @@ CPPFLAGS += \ | ||
| 105 | |||
| 106 | LDFLAGS += \ | ||
| 107 | -Ldebian/out/system/core \ | ||
| 108 | - -Wl,-rpath=/usr/lib/$(DEB_HOST_MULTIARCH)/android \ | ||
| 109 | + -Wl,-rpath='$$ORIGIN/../lib/android' \ | ||
| 110 | -lbase \ | ||
| 111 | -llog \ | ||
| 112 | -lpthread \ | ||
| 113 | diff --git a/debian/system/core/fastboot.mk b/debian/system/core/fastboot.mk | ||
| 114 | index d5c9a285..a59ba1a4 100644 | ||
| 115 | --- a/debian/system/core/fastboot.mk | ||
| 116 | +++ b/debian/system/core/fastboot.mk | ||
| 117 | @@ -30,7 +30,6 @@ CXXFLAGS += -std=gnu++2a -fpermissive | ||
| 118 | CPPFLAGS += \ | ||
| 119 | -D_FILE_OFFSET_BITS=64 \ | ||
| 120 | -DPLATFORM_TOOLS_VERSION='"$(PLATFORM_TOOLS_VERSION)"' \ | ||
| 121 | - -I/usr/include/android \ | ||
| 122 | -Iexternal/boringssl/include \ | ||
| 123 | -Iexternal/avb \ | ||
| 124 | -Isystem/core/adb \ | ||
| 125 | @@ -49,8 +48,7 @@ CPPFLAGS += \ | ||
| 126 | |||
| 127 | LDFLAGS += \ | ||
| 128 | -Ldebian/out/system/core \ | ||
| 129 | - -Wl,-rpath=/usr/lib/$(DEB_HOST_MULTIARCH)/android \ | ||
| 130 | - -fuse-ld=gold \ | ||
| 131 | + -Wl,-rpath='$$ORIGIN/../lib/android' \ | ||
| 132 | -lbase \ | ||
| 133 | -lcutils \ | ||
| 134 | -lpthread \ | ||
| 135 | diff --git a/debian/system/core/img2simg.mk b/debian/system/core/img2simg.mk | ||
| 136 | index 11adf014..8baf5ba5 100644 | ||
| 137 | --- a/debian/system/core/img2simg.mk | ||
| 138 | +++ b/debian/system/core/img2simg.mk | ||
| 139 | @@ -11,7 +11,7 @@ CPPFLAGS += \ | ||
| 140 | |||
| 141 | LDFLAGS += \ | ||
| 142 | -Ldebian/out/system/core \ | ||
| 143 | - -Wl,-rpath=/usr/lib/$(DEB_HOST_MULTIARCH)/android \ | ||
| 144 | + -Wl,-rpath='$$ORIGIN/../lib/android' \ | ||
| 145 | -lbase \ | ||
| 146 | -llog \ | ||
| 147 | -lpthread \ | ||
| 148 | diff --git a/debian/system/core/libbacktrace.mk b/debian/system/core/libbacktrace.mk | ||
| 149 | index e3411d76..e7dd984c 100644 | ||
| 150 | --- a/debian/system/core/libbacktrace.mk | ||
| 151 | +++ b/debian/system/core/libbacktrace.mk | ||
| 152 | @@ -1,4 +1,4 @@ | ||
| 153 | -include /usr/share/dpkg/architecture.mk | ||
| 154 | +include rules_yocto.mk | ||
| 155 | |||
| 156 | NAME = libbacktrace | ||
| 157 | |||
| 158 | @@ -81,12 +81,10 @@ CPPFLAGS += \ | ||
| 159 | -Isystem/core/libunwindstack/include \ | ||
| 160 | |||
| 161 | LDFLAGS += \ | ||
| 162 | - -L/usr/lib/p7zip \ | ||
| 163 | -Ldebian/out/system/core \ | ||
| 164 | - -Wl,-rpath=/usr/lib/p7zip \ | ||
| 165 | - -Wl,-rpath=/usr/lib/$(DEB_HOST_MULTIARCH)/android \ | ||
| 166 | + -Wl,-rpath='$$ORIGIN' \ | ||
| 167 | -Wl,-soname,$(NAME).so.0 \ | ||
| 168 | - -l:7z.so \ | ||
| 169 | + -l7z \ | ||
| 170 | -lbase \ | ||
| 171 | -llog \ | ||
| 172 | -lpthread \ | ||
| 173 | @@ -101,7 +99,7 @@ endif | ||
| 174 | build: $(OBJECTS_CXX) $(OBJECTS_ASSEMBLY) debian/out/external/libunwind/libunwind.a | ||
| 175 | mkdir -p debian/out/system/core | ||
| 176 | $(CXX) $^ -o debian/out/system/core/$(NAME).so.0 $(LDFLAGS) | ||
| 177 | - cd debian/out/system/core && ln -s $(NAME).so.0 $(NAME).so | ||
| 178 | + cd debian/out/system/core && ln -sf $(NAME).so.0 $(NAME).so | ||
| 179 | |||
| 180 | $(OBJECTS_CXX): %.o: %.cpp | ||
| 181 | $(CXX) -c -o $@ $< $(CXXFLAGS) $(CPPFLAGS) | ||
| 182 | diff --git a/debian/system/core/libbase.mk b/debian/system/core/libbase.mk | ||
| 183 | index d2b074ba..8a90d6de 100644 | ||
| 184 | --- a/debian/system/core/libbase.mk | ||
| 185 | +++ b/debian/system/core/libbase.mk | ||
| 186 | @@ -1,3 +1,4 @@ | ||
| 187 | +include rules_yocto.mk | ||
| 188 | NAME = libbase | ||
| 189 | |||
| 190 | SOURCES = \ | ||
| 191 | @@ -30,7 +31,7 @@ CPPFLAGS += \ | ||
| 192 | |||
| 193 | LDFLAGS += \ | ||
| 194 | -Ldebian/out/system/core \ | ||
| 195 | - -Wl,-rpath=/usr/lib/$(DEB_HOST_MULTIARCH)/android \ | ||
| 196 | + -Wl,-rpath='$$ORIGIN' \ | ||
| 197 | -Wl,-soname,$(NAME).so.0 \ | ||
| 198 | -llog \ | ||
| 199 | -lpthread \ | ||
| 200 | @@ -44,7 +45,7 @@ endif | ||
| 201 | |||
| 202 | build: $(OBJECTS) | ||
| 203 | $(CXX) $^ -o debian/out/system/core/$(NAME).so.0 $(LDFLAGS) | ||
| 204 | - cd debian/out/system/core && ln -s $(NAME).so.0 $(NAME).so | ||
| 205 | + cd debian/out/system/core && ln -sf $(NAME).so.0 $(NAME).so | ||
| 206 | |||
| 207 | $(OBJECTS): %.o: %.cpp | ||
| 208 | $(CXX) -c -o $@ $< $(CXXFLAGS) $(CPPFLAGS) | ||
| 209 | diff --git a/debian/system/core/libcutils.mk b/debian/system/core/libcutils.mk | ||
| 210 | index 9d928b56..c22b0965 100644 | ||
| 211 | --- a/debian/system/core/libcutils.mk | ||
| 212 | +++ b/debian/system/core/libcutils.mk | ||
| 213 | @@ -1,3 +1,4 @@ | ||
| 214 | +include rules_yocto.mk | ||
| 215 | NAME = libcutils | ||
| 216 | |||
| 217 | libcutils_nonwindows_sources = \ | ||
| 218 | @@ -47,7 +48,7 @@ CPPFLAGS += \ | ||
| 219 | |||
| 220 | LDFLAGS += \ | ||
| 221 | -Ldebian/out/system/core \ | ||
| 222 | - -Wl,-rpath=/usr/lib/$(DEB_HOST_MULTIARCH)/android \ | ||
| 223 | + -Wl,-rpath='$$ORIGIN' \ | ||
| 224 | -Wl,-soname,$(NAME).so.0 \ | ||
| 225 | -lbase \ | ||
| 226 | -llog \ | ||
| 227 | @@ -56,7 +57,7 @@ LDFLAGS += \ | ||
| 228 | |||
| 229 | build: $(OBJECTS_C) $(OBJECTS_CXX) | ||
| 230 | $(CXX) $^ -o debian/out/system/core/$(NAME).so.0 $(LDFLAGS) | ||
| 231 | - cd debian/out/system/core && ln -s $(NAME).so.0 $(NAME).so | ||
| 232 | + cd debian/out/system/core && ln -sf $(NAME).so.0 $(NAME).so | ||
| 233 | |||
| 234 | $(OBJECTS_C): %.o: %.c | ||
| 235 | $(CC) -c -o $@ $< $(CFLAGS) $(CPPFLAGS) | ||
| 236 | diff --git a/debian/system/core/liblog.mk b/debian/system/core/liblog.mk | ||
| 237 | index f8c3d7fe..34a07341 100644 | ||
| 238 | --- a/debian/system/core/liblog.mk | ||
| 239 | +++ b/debian/system/core/liblog.mk | ||
| 240 | @@ -1,3 +1,4 @@ | ||
| 241 | +include rules_yocto.mk | ||
| 242 | NAME = liblog | ||
| 243 | |||
| 244 | liblog_sources = \ | ||
| 245 | @@ -35,7 +36,7 @@ LDFLAGS += \ | ||
| 246 | build: $(OBJECTS) | ||
| 247 | mkdir -p debian/out/system/core | ||
| 248 | $(CXX) $^ -o debian/out/system/core/$(NAME).so.0 $(LDFLAGS) | ||
| 249 | - cd debian/out/system/core && ln -s $(NAME).so.0 $(NAME).so | ||
| 250 | + cd debian/out/system/core && ln -sf $(NAME).so.0 $(NAME).so | ||
| 251 | |||
| 252 | $(OBJECTS): %.o: %.cpp | ||
| 253 | $(CXX) -c -o $@ $< $(CXXFLAGS) $(CPPFLAGS) | ||
| 254 | diff --git a/debian/system/core/libsparse.mk b/debian/system/core/libsparse.mk | ||
| 255 | index c2b2694c..2da12b8e 100644 | ||
| 256 | --- a/debian/system/core/libsparse.mk | ||
| 257 | +++ b/debian/system/core/libsparse.mk | ||
| 258 | @@ -1,3 +1,4 @@ | ||
| 259 | +include rules_yocto.mk | ||
| 260 | NAME = libsparse | ||
| 261 | |||
| 262 | SOURCES = \ | ||
| 263 | @@ -19,7 +20,7 @@ CPPFLAGS += \ | ||
| 264 | |||
| 265 | LDFLAGS += \ | ||
| 266 | -Ldebian/out/system/core \ | ||
| 267 | - -Wl,-rpath=/usr/lib/$(DEB_HOST_MULTIARCH)/android \ | ||
| 268 | + -Wl,-rpath='$$ORIGIN' \ | ||
| 269 | -Wl,-soname,$(NAME).so.0 \ | ||
| 270 | -lbase \ | ||
| 271 | -lz \ | ||
| 272 | @@ -27,7 +28,7 @@ LDFLAGS += \ | ||
| 273 | |||
| 274 | build: $(OBJECTS) | ||
| 275 | $(CXX) $^ -o debian/out/system/core/$(NAME).so.0 $(LDFLAGS) | ||
| 276 | - cd debian/out/system/core && ln -s $(NAME).so.0 $(NAME).so | ||
| 277 | + cd debian/out/system/core && ln -sf $(NAME).so.0 $(NAME).so | ||
| 278 | |||
| 279 | $(OBJECTS): %.o: %.cpp | ||
| 280 | $(CXX) -c -o $@ $< $(CXXFLAGS) $(CPPFLAGS) | ||
| 281 | diff --git a/debian/system/core/libutils.mk b/debian/system/core/libutils.mk | ||
| 282 | index c37b1d2d..0c748c8b 100644 | ||
| 283 | --- a/debian/system/core/libutils.mk | ||
| 284 | +++ b/debian/system/core/libutils.mk | ||
| 285 | @@ -1,4 +1,4 @@ | ||
| 286 | -include /usr/share/dpkg/architecture.mk | ||
| 287 | +include rules_yocto.mk | ||
| 288 | |||
| 289 | NAME = libutils | ||
| 290 | |||
| 291 | @@ -41,7 +41,7 @@ CPPFLAGS += \ | ||
| 292 | |||
| 293 | LDFLAGS += \ | ||
| 294 | -Ldebian/out/system/core \ | ||
| 295 | - -Wl,-rpath=/usr/lib/$(DEB_HOST_MULTIARCH)/android \ | ||
| 296 | + -Wl,-rpath='$$ORIGIN' \ | ||
| 297 | -Wl,-soname,$(NAME).so.0 \ | ||
| 298 | -lbacktrace \ | ||
| 299 | -lcutils \ | ||
| 300 | diff --git a/debian/system/core/libziparchive.mk b/debian/system/core/libziparchive.mk | ||
| 301 | index 1b286b4e..1b7499be 100644 | ||
| 302 | --- a/debian/system/core/libziparchive.mk | ||
| 303 | +++ b/debian/system/core/libziparchive.mk | ||
| 304 | @@ -1,3 +1,4 @@ | ||
| 305 | +include rules_yocto.mk | ||
| 306 | NAME = libziparchive | ||
| 307 | |||
| 308 | SOURCES = \ | ||
| 309 | @@ -19,7 +20,7 @@ CPPFLAGS += \ | ||
| 310 | |||
| 311 | LDFLAGS += \ | ||
| 312 | -Ldebian/out/system/core \ | ||
| 313 | - -Wl,-rpath=/usr/lib/$(DEB_HOST_MULTIARCH)/android \ | ||
| 314 | + -Wl,-rpath='$$ORIGIN' \ | ||
| 315 | -Wl,-soname,$(NAME).so.0 \ | ||
| 316 | -lbase \ | ||
| 317 | -llog \ | ||
| 318 | @@ -29,7 +30,7 @@ LDFLAGS += \ | ||
| 319 | |||
| 320 | build: $(OBJECTS) | ||
| 321 | $(CXX) $^ -o debian/out/system/core/$(NAME).so.0 $(LDFLAGS) | ||
| 322 | - cd debian/out/system/core && ln -s $(NAME).so.0 $(NAME).so | ||
| 323 | + cd debian/out/system/core && ln -sf $(NAME).so.0 $(NAME).so | ||
| 324 | |||
| 325 | $(OBJECTS): %.o: %.cc | ||
| 326 | $(CXX) -c -o $@ $< $(CXXFLAGS) $(CPPFLAGS) | ||
| 327 | diff --git a/debian/system/core/simg2img.mk b/debian/system/core/simg2img.mk | ||
| 328 | index f6e3f59d..df4f44f3 100644 | ||
| 329 | --- a/debian/system/core/simg2img.mk | ||
| 330 | +++ b/debian/system/core/simg2img.mk | ||
| 331 | @@ -13,7 +13,7 @@ CPPFLAGS += \ | ||
| 332 | |||
| 333 | LDFLAGS += \ | ||
| 334 | -Ldebian/out/system/core \ | ||
| 335 | - -Wl,-rpath=/usr/lib/$(DEB_HOST_MULTIARCH)/android \ | ||
| 336 | + -Wl,-rpath='$$ORIGIN/../lib/android' \ | ||
| 337 | -lbase \ | ||
| 338 | -llog \ | ||
| 339 | -lpthread \ | ||
| 340 | diff --git a/debian/system/core/simg2simg.mk b/debian/system/core/simg2simg.mk | ||
| 341 | index ed53b04c..646ab030 100644 | ||
| 342 | --- a/debian/system/core/simg2simg.mk | ||
| 343 | +++ b/debian/system/core/simg2simg.mk | ||
| 344 | @@ -13,7 +13,7 @@ CPPFLAGS += \ | ||
| 345 | |||
| 346 | LDFLAGS += \ | ||
| 347 | -Ldebian/out/system/core \ | ||
| 348 | - -Wl,-rpath=/usr/lib/$(DEB_HOST_MULTIARCH)/android \ | ||
| 349 | + -Wl,-rpath='$$ORIGIN/../lib/android' \ | ||
| 350 | -lbase \ | ||
| 351 | -llog \ | ||
| 352 | -lpthread \ | ||
| 353 | diff --git a/debian/system/extras/libext4_utils.mk b/debian/system/extras/libext4_utils.mk | ||
| 354 | index 264bb95ad36a..99125097c8e3 100644 | ||
| 355 | --- a/debian/system/extras/libext4_utils.mk | ||
| 356 | +++ b/debian/system/extras/libext4_utils.mk | ||
| 357 | @@ -25,7 +25,6 @@ CPPFLAGS += \ | ||
| 358 | -D_LARGEFILE64_SOURCE \ | ||
| 359 | -DFEC_NO_KLOG \ | ||
| 360 | -DSQUASHFS_NO_KLOG \ | ||
| 361 | - -I/usr/include/android \ | ||
| 362 | -Isystem/core/base/include \ | ||
| 363 | -Isystem/core/libcutils/include \ | ||
| 364 | -Isystem/core/libsparse/include \ | ||
| 365 | diff --git a/frameworks/native/libs/adbd_auth/adbd_auth.cpp b/frameworks/native/libs/adbd_auth/adbd_auth.cpp | ||
| 366 | index a9c23110..6ca334ba 100644 | ||
| 367 | --- a/frameworks/native/libs/adbd_auth/adbd_auth.cpp | ||
| 368 | +++ b/frameworks/native/libs/adbd_auth/adbd_auth.cpp | ||
| 369 | @@ -23,8 +23,10 @@ | ||
| 370 | #include <sys/eventfd.h> | ||
| 371 | #include <sys/uio.h> | ||
| 372 | |||
| 373 | +#include <atomic> | ||
| 374 | #include <chrono> | ||
| 375 | #include <deque> | ||
| 376 | +#include <optional> | ||
| 377 | #include <string> | ||
| 378 | #include <string_view> | ||
| 379 | #include <tuple> | ||
| 380 | diff --git a/system/core/adb/adb_listeners.cpp b/system/core/adb/adb_listeners.cpp | ||
| 381 | index 29909a55..440cdbd4 100644 | ||
| 382 | --- a/system/core/adb/adb_listeners.cpp | ||
| 383 | +++ b/system/core/adb/adb_listeners.cpp | ||
| 384 | @@ -109,7 +109,7 @@ static void listener_event_func(int _fd, unsigned ev, void* _l) | ||
| 385 | } | ||
| 386 | |||
| 387 | // Called as a transport disconnect function. |arg| is the raw alistener*. | ||
| 388 | -static void listener_disconnect(void* arg, atransport*) EXCLUDES(listener_list_mutex) { | ||
| 389 | +static void listener_disconnect(void* arg, atransport*) { | ||
| 390 | std::lock_guard<std::mutex> lock(listener_list_mutex); | ||
| 391 | for (auto iter = listener_list.begin(); iter != listener_list.end(); ++iter) { | ||
| 392 | if (iter->get() == arg) { | ||
| 393 | @@ -121,7 +121,7 @@ static void listener_disconnect(void* arg, atransport*) EXCLUDES(listener_list_m | ||
| 394 | } | ||
| 395 | |||
| 396 | // Write the list of current listeners (network redirections) into a string. | ||
| 397 | -std::string format_listeners() EXCLUDES(listener_list_mutex) { | ||
| 398 | +std::string format_listeners() { | ||
| 399 | std::lock_guard<std::mutex> lock(listener_list_mutex); | ||
| 400 | std::string result; | ||
| 401 | for (auto& l : listener_list) { | ||
| 402 | @@ -140,7 +140,7 @@ std::string format_listeners() EXCLUDES(listener_list_mutex) { | ||
| 403 | } | ||
| 404 | |||
| 405 | InstallStatus remove_listener(const char* local_name, atransport* transport) | ||
| 406 | - EXCLUDES(listener_list_mutex) { | ||
| 407 | +{ | ||
| 408 | std::lock_guard<std::mutex> lock(listener_list_mutex); | ||
| 409 | for (auto iter = listener_list.begin(); iter != listener_list.end(); ++iter) { | ||
| 410 | if (local_name == (*iter)->local_name) { | ||
| 411 | @@ -151,7 +151,7 @@ InstallStatus remove_listener(const char* local_name, atransport* transport) | ||
| 412 | return INSTALL_STATUS_LISTENER_NOT_FOUND; | ||
| 413 | } | ||
| 414 | |||
| 415 | -void remove_all_listeners() EXCLUDES(listener_list_mutex) { | ||
| 416 | +void remove_all_listeners() { | ||
| 417 | std::lock_guard<std::mutex> lock(listener_list_mutex); | ||
| 418 | auto iter = listener_list.begin(); | ||
| 419 | while (iter != listener_list.end()) { | ||
| 420 | @@ -164,7 +164,7 @@ void remove_all_listeners() EXCLUDES(listener_list_mutex) { | ||
| 421 | } | ||
| 422 | } | ||
| 423 | |||
| 424 | -void close_smartsockets() EXCLUDES(listener_list_mutex) { | ||
| 425 | +void close_smartsockets() { | ||
| 426 | std::lock_guard<std::mutex> lock(listener_list_mutex); | ||
| 427 | auto pred = [](const std::unique_ptr<alistener>& listener) { | ||
| 428 | return listener->local_name == "*smartsocket*"; | ||
| 429 | @@ -174,7 +174,7 @@ void close_smartsockets() EXCLUDES(listener_list_mutex) { | ||
| 430 | |||
| 431 | InstallStatus install_listener(const std::string& local_name, const char* connect_to, | ||
| 432 | atransport* transport, int no_rebind, int* resolved_tcp_port, | ||
| 433 | - std::string* error) EXCLUDES(listener_list_mutex) { | ||
| 434 | + std::string* error) { | ||
| 435 | std::lock_guard<std::mutex> lock(listener_list_mutex); | ||
| 436 | for (auto& l : listener_list) { | ||
| 437 | if (local_name == l->local_name) { | ||
| 438 | diff --git a/system/core/adb/transport_local.cpp b/system/core/adb/transport_local.cpp | ||
| 439 | index c7261860..5988ec4d 100644 | ||
| 440 | --- a/system/core/adb/transport_local.cpp | ||
| 441 | +++ b/system/core/adb/transport_local.cpp | ||
| 442 | @@ -333,7 +333,7 @@ struct EmulatorConnection : public FdConnection { | ||
| 443 | |||
| 444 | /* Only call this function if you already hold local_transports_lock. */ | ||
| 445 | static atransport* find_emulator_transport_by_adb_port_locked(int adb_port) | ||
| 446 | - REQUIRES(local_transports_lock) { | ||
| 447 | +{ | ||
| 448 | auto it = local_transports.find(adb_port); | ||
| 449 | if (it == local_transports.end()) { | ||
| 450 | return nullptr; | ||
| 451 | -- | ||
| 452 | 2.34.1 | ||
| 453 | |||
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 @@ | |||
| 1 | From 02b6b6977d80af4b9b806054fadb5a06cedf011d Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Etienne Cordonnier <ecordonnier@snap.com> | ||
| 3 | Date: Tue, 14 Mar 2023 11:33:50 +0100 | ||
| 4 | Subject: [PATCH] Update usage of usbdevfs_urb to match new kernel UAPI | ||
| 5 | MIME-Version: 1.0 | ||
| 6 | Content-Type: text/plain; charset=UTF-8 | ||
| 7 | Content-Transfer-Encoding: 8bit | ||
| 8 | |||
| 9 | Linux kernel API has been changed by commit 94dfc73e7cf4 ("treewide: uapi: Replace zero-length arrays with flexible-array members") | ||
| 10 | where zero-length array iso_frame_desc in struct usbdevfs_urb was replaced with a proper flexible-array member. | ||
| 11 | |||
| 12 | Current USB API usage causes a compilation error at Linux 6.0: | ||
| 13 | |||
| 14 | In file included from /home/mae/.cache/kiss/proc/121205/build/android-tools/vendor/adb/client/usb_linux.cpp:28: | ||
| 15 | /usr/include/linux/usbdevice_fs.h:134:41: error: flexible array member ‘usbdevfs_urb::iso_frame_desc’ not at end of ‘struct usb_handle’ | ||
| 16 | 134 | struct usbdevfs_iso_packet_desc iso_frame_desc[]; | ||
| 17 | | ^~~~~~~~~~~~~~ | ||
| 18 | /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 | ||
| 19 | 76 | usbdevfs_urb urb_out; | ||
| 20 | | ^~~~~~~ | ||
| 21 | /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’ | ||
| 22 | 61 | struct usb_handle { | ||
| 23 | | ^~~~~~~~~~ | ||
| 24 | |||
| 25 | Fix it by using pointers to a struct with flexible-array members. | ||
| 26 | Current fix works both with the old and the new API. | ||
| 27 | |||
| 28 | See https://github.com/nmeum/android-tools/issues/74 for more context. | ||
| 29 | |||
| 30 | Tested: built on Linux against kernel 5.19 and 6.0; 'adb shell' over USB | ||
| 31 | cable | ||
| 32 | Acked-by: Gustavo A. R. Silva gustavoars@kernel.org | ||
| 33 | Change-Id: I7f0f7b35d9a3ab980d3520b541b60c7857a6b101 | ||
| 34 | Signed-off-by: Anatol Pomozov <anatol.pomozov@gmail.com> | ||
| 35 | |||
| 36 | [Backported on version 10] | ||
| 37 | Signed-off-by: Etienne Cordonnier <ecordonnier@snap.com> | ||
| 38 | |||
| 39 | --- | ||
| 40 | Upstream-Status: Pending | ||
| 41 | |||
| 42 | system/core/adb/client/usb_linux.cpp | 24 ++++++++++++++---------- | ||
| 43 | 1 file changed, 14 insertions(+), 10 deletions(-) | ||
| 44 | |||
| 45 | diff --git a/system/core/adb/client/usb_linux.cpp b/system/core/adb/client/usb_linux.cpp | ||
| 46 | index 343e7b59..6a4479f3 100644 | ||
| 47 | --- a/system/core/adb/client/usb_linux.cpp | ||
| 48 | +++ b/system/core/adb/client/usb_linux.cpp | ||
| 49 | @@ -71,8 +71,8 @@ struct usb_handle : public ::usb_handle { | ||
| 50 | unsigned zero_mask; | ||
| 51 | unsigned writeable = 1; | ||
| 52 | |||
| 53 | - usbdevfs_urb urb_in; | ||
| 54 | - usbdevfs_urb urb_out; | ||
| 55 | + usbdevfs_urb *urb_in; | ||
| 56 | + usbdevfs_urb *urb_out; | ||
| 57 | |||
| 58 | bool urb_in_busy = false; | ||
| 59 | bool urb_out_busy = false; | ||
| 60 | @@ -305,7 +305,7 @@ static int usb_bulk_write(usb_handle* h, const void* data, int len) { | ||
| 61 | std::unique_lock<std::mutex> lock(h->mutex); | ||
| 62 | D("++ usb_bulk_write ++"); | ||
| 63 | |||
| 64 | - usbdevfs_urb* urb = &h->urb_out; | ||
| 65 | + usbdevfs_urb* urb = h->urb_out; | ||
| 66 | memset(urb, 0, sizeof(*urb)); | ||
| 67 | urb->type = USBDEVFS_URB_TYPE_BULK; | ||
| 68 | urb->endpoint = h->ep_out; | ||
| 69 | @@ -344,7 +344,7 @@ static int usb_bulk_read(usb_handle* h, void* data, int len) { | ||
| 70 | std::unique_lock<std::mutex> lock(h->mutex); | ||
| 71 | D("++ usb_bulk_read ++"); | ||
| 72 | |||
| 73 | - usbdevfs_urb* urb = &h->urb_in; | ||
| 74 | + usbdevfs_urb* urb = h->urb_in; | ||
| 75 | memset(urb, 0, sizeof(*urb)); | ||
| 76 | urb->type = USBDEVFS_URB_TYPE_BULK; | ||
| 77 | urb->endpoint = h->ep_in; | ||
| 78 | @@ -389,7 +389,7 @@ static int usb_bulk_read(usb_handle* h, void* data, int len) { | ||
| 79 | } | ||
| 80 | D("[ urb @%p status = %d, actual = %d ]", out, out->status, out->actual_length); | ||
| 81 | |||
| 82 | - if (out == &h->urb_in) { | ||
| 83 | + if (out == h->urb_in) { | ||
| 84 | D("[ reap urb - IN complete ]"); | ||
| 85 | h->urb_in_busy = false; | ||
| 86 | if (urb->status != 0) { | ||
| 87 | @@ -398,7 +398,7 @@ static int usb_bulk_read(usb_handle* h, void* data, int len) { | ||
| 88 | } | ||
| 89 | return urb->actual_length; | ||
| 90 | } | ||
| 91 | - if (out == &h->urb_out) { | ||
| 92 | + if (out == h->urb_out) { | ||
| 93 | D("[ reap urb - OUT compelete ]"); | ||
| 94 | h->urb_out_busy = false; | ||
| 95 | h->cv.notify_all(); | ||
| 96 | @@ -502,10 +502,10 @@ void usb_kick(usb_handle* h) { | ||
| 97 | ** but this ensures that a reader blocked on REAPURB | ||
| 98 | ** will get unblocked | ||
| 99 | */ | ||
| 100 | - ioctl(h->fd, USBDEVFS_DISCARDURB, &h->urb_in); | ||
| 101 | - ioctl(h->fd, USBDEVFS_DISCARDURB, &h->urb_out); | ||
| 102 | - h->urb_in.status = -ENODEV; | ||
| 103 | - h->urb_out.status = -ENODEV; | ||
| 104 | + ioctl(h->fd, USBDEVFS_DISCARDURB, h->urb_in); | ||
| 105 | + ioctl(h->fd, USBDEVFS_DISCARDURB, h->urb_out); | ||
| 106 | + h->urb_in->status = -ENODEV; | ||
| 107 | + h->urb_out->status = -ENODEV; | ||
| 108 | h->urb_in_busy = false; | ||
| 109 | h->urb_out_busy = false; | ||
| 110 | h->cv.notify_all(); | ||
| 111 | @@ -521,6 +521,8 @@ int usb_close(usb_handle* h) { | ||
| 112 | |||
| 113 | D("-- usb close %p (fd = %d) --", h, h->fd); | ||
| 114 | |||
| 115 | + delete h->urb_in; | ||
| 116 | + delete h->urb_out; | ||
| 117 | delete h; | ||
| 118 | |||
| 119 | return 0; | ||
| 120 | @@ -556,6 +558,8 @@ static void register_device(const char* dev_name, const char* dev_path, unsigned | ||
| 121 | usb->ep_out = ep_out; | ||
| 122 | usb->zero_mask = zero_mask; | ||
| 123 | usb->max_packet_size = max_packet_size; | ||
| 124 | + usb->urb_in = new usbdevfs_urb; | ||
| 125 | + usb->urb_out = new usbdevfs_urb; | ||
| 126 | |||
| 127 | // Initialize mark so we don't get garbage collected after the device scan. | ||
| 128 | 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 @@ | |||
| 1 | From e4a29888cb52c1eafd3ab57a6e220b38147ecfbe Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Etienne Cordonnier <ecordonnier@snap.com> | ||
| 3 | Date: Tue, 14 Mar 2023 13:39:23 +0100 | ||
| 4 | Subject: [PATCH] adb: Fix build on big endian systems | ||
| 5 | |||
| 6 | The usb_linux_client.c file defines cpu_to_le16/32 by using the C | ||
| 7 | library htole16/32 function calls. However, cpu_to_le16/32 are used | ||
| 8 | when initializing structures, i.e in a context where a function call | ||
| 9 | is not allowed. | ||
| 10 | |||
| 11 | It works fine on little endian systems because htole16/32 are defined | ||
| 12 | by the C library as no-ops. But on big-endian systems, they are | ||
| 13 | actually doing something, which might involve calling a function, | ||
| 14 | causing build failures. | ||
| 15 | |||
| 16 | To solve this, we simply open-code cpu_to_le16/32 in a way that allows | ||
| 17 | them to be used when initializing structures. | ||
| 18 | |||
| 19 | Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com> | ||
| 20 | [Forward-ported to version 29] | ||
| 21 | Signed-off-by: Etienne Cordonnier <ecordonnier@snap.com> | ||
| 22 | |||
| 23 | --- | ||
| 24 | Upstream-Status: Pending | ||
| 25 | |||
| 26 | system/core/adb/daemon/usb_ffs.cpp | 11 +++++++++-- | ||
| 27 | 1 file changed, 9 insertions(+), 2 deletions(-) | ||
| 28 | |||
| 29 | diff --git a/system/core/adb/daemon/usb_ffs.cpp b/system/core/adb/daemon/usb_ffs.cpp | ||
| 30 | index b19fa5d5..ef2291ca 100644 | ||
| 31 | --- a/system/core/adb/daemon/usb_ffs.cpp | ||
| 32 | +++ b/system/core/adb/daemon/usb_ffs.cpp | ||
| 33 | @@ -39,8 +39,15 @@ | ||
| 34 | |||
| 35 | #define USB_EXT_PROP_UNICODE 1 | ||
| 36 | |||
| 37 | -#define cpu_to_le16(x) htole16(x) | ||
| 38 | -#define cpu_to_le32(x) htole32(x) | ||
| 39 | +#if __BYTE_ORDER == __LITTLE_ENDIAN | ||
| 40 | +# define cpu_to_le16(x) (x) | ||
| 41 | +# define cpu_to_le32(x) (x) | ||
| 42 | +#else | ||
| 43 | +# define cpu_to_le16(x) ((((x) >> 8) & 0xffu) | (((x) & 0xffu) << 8)) | ||
| 44 | +# define cpu_to_le32(x) \ | ||
| 45 | + ((((x) & 0xff000000u) >> 24) | (((x) & 0x00ff0000u) >> 8) | \ | ||
| 46 | + (((x) & 0x0000ff00u) << 8) | (((x) & 0x000000ffu) << 24)) | ||
| 47 | +#endif | ||
| 48 | |||
| 49 | // clang-format off | ||
| 50 | 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 @@ | |||
| 1 | From 4ef35041ba5c02df48c31f2382e7c3c4316ad936 Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Etienne Cordonnier <ecordonnier@snap.com> | ||
| 3 | Date: Tue, 14 Mar 2023 13:53:51 +0100 | ||
| 4 | Subject: [PATCH] adb: Allow adbd to be run as root | ||
| 5 | |||
| 6 | Signed-off-by: Etienne Cordonnier <ecordonnier@snap.com> | ||
| 7 | |||
| 8 | --- | ||
| 9 | Upstream-Status: Pending | ||
| 10 | |||
| 11 | system/core/adb/daemon/main.cpp | 1 + | ||
| 12 | 1 file changed, 1 insertion(+) | ||
| 13 | |||
| 14 | diff --git a/system/core/adb/daemon/main.cpp b/system/core/adb/daemon/main.cpp | ||
| 15 | index e807d13d..309663a2 100644 | ||
| 16 | --- a/system/core/adb/daemon/main.cpp | ||
| 17 | +++ b/system/core/adb/daemon/main.cpp | ||
| 18 | @@ -75,6 +75,7 @@ static bool should_drop_capabilities_bounding_set() { | ||
| 19 | } | ||
| 20 | |||
| 21 | static bool should_drop_privileges() { | ||
| 22 | + return true; | ||
| 23 | // "adb root" not allowed, always drop privileges. | ||
| 24 | if (!ALLOW_ADBD_ROOT && !is_device_unlocked()) return true; | ||
| 25 | |||
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 @@ | |||
| 1 | include rules_yocto.mk | ||
| 2 | NAME = adbd | ||
| 3 | |||
| 4 | SOURCES = \ | ||
| 5 | adb/adbconnection/adbconnection_server.cpp \ | ||
| 6 | adb/daemon/auth.cpp \ | ||
| 7 | adb/daemon/file_sync_service.cpp \ | ||
| 8 | adb/daemon/file_sync_service.h \ | ||
| 9 | adb/daemon/framebuffer_service.cpp \ | ||
| 10 | adb/daemon/framebuffer_service.h \ | ||
| 11 | adb/daemon/jdwp_service.cpp \ | ||
| 12 | adb/daemon/main.cpp \ | ||
| 13 | adb/daemon/restart_service.cpp \ | ||
| 14 | adb/daemon/restart_service.h \ | ||
| 15 | adb/daemon/services.cpp \ | ||
| 16 | adb/daemon/shell_service.cpp \ | ||
| 17 | adb/daemon/shell_service.h \ | ||
| 18 | adb/daemon/usb_ffs.cpp \ | ||
| 19 | adb/daemon/usb_legacy.cpp \ | ||
| 20 | adb/daemon/usb.cpp \ | ||
| 21 | adb/shell_service_protocol.cpp \ | ||
| 22 | adb/adb.cpp \ | ||
| 23 | adb/adb_io.cpp \ | ||
| 24 | adb/adb_listeners.cpp \ | ||
| 25 | adb/adb_trace.cpp \ | ||
| 26 | adb/adb_unique_fd.cpp \ | ||
| 27 | adb/adb_utils.cpp \ | ||
| 28 | adb/fdevent/fdevent.cpp \ | ||
| 29 | adb/fdevent/fdevent_epoll.cpp \ | ||
| 30 | adb/services.cpp \ | ||
| 31 | adb/sockets.cpp \ | ||
| 32 | adb/socket_spec.cpp \ | ||
| 33 | adb/sysdeps/errno.cpp \ | ||
| 34 | adb/sysdeps/posix/network.cpp \ | ||
| 35 | adb/sysdeps_unix.cpp \ | ||
| 36 | adb/transport.cpp \ | ||
| 37 | adb/transport_fd.cpp \ | ||
| 38 | adb/transport_local.cpp \ | ||
| 39 | adb/transport_usb.cpp \ | ||
| 40 | adb/types.cpp \ | ||
| 41 | diagnose_usb/diagnose_usb.cpp \ | ||
| 42 | libasyncio/AsyncIO.cpp \ | ||
| 43 | |||
| 44 | SOURCES := $(foreach source, $(SOURCES), system/core/$(source)) | ||
| 45 | |||
| 46 | SOURCES += \ | ||
| 47 | frameworks/native/libs/adbd_auth/adbd_auth.cpp | ||
| 48 | |||
| 49 | CXXFLAGS += -std=gnu++20 | ||
| 50 | CPPFLAGS += -Isystem/coreinclude -Isystem/core/adb -Isystem/core/base/include -Idebian/out/system/core -Isystem/tools/mkbootimg/include/bootimg -Isystem/core/fs_mgr/include \ | ||
| 51 | -Isystem/core/fs_mgr/include_fstab \ | ||
| 52 | -DADB_VERSION='"$(DEB_VERSION)"' -D_GNU_SOURCE | ||
| 53 | LDFLAGS += -Wl,-rpath='$$ORIGIN/../lib/android' -Wl,-rpath-link='$$ORIGIN/../lib/android' \ | ||
| 54 | -lpthread -Ldebian/out/system/core -Ldebian/out/external/boringssl -lbase -lcrypto_utils -l:libcrypto.a -lcutils -llog -lresolv | ||
| 55 | |||
| 56 | PAGE_SIZE ?= 4096 | ||
| 57 | |||
| 58 | CXXFLAGS += -UADB_HOST | ||
| 59 | CXXFLAGS += -DADB_HOST=0 | ||
| 60 | CXXFLAGS += -DALLOW_ADBD_DISABLE_VERITY | ||
| 61 | CXXFLAGS += -DALLOW_ADBD_NO_AUTH | ||
| 62 | CXXFLAGS += -DPLATFORM_TOOLS_VERSION='"28.0.2"' | ||
| 63 | CXXFLAGS += -Isystem/core/diagnose_usb/include | ||
| 64 | CXXFLAGS += -Isystem/core/adb/daemon/include | ||
| 65 | CXXFLAGS += -Isystem/core/adb/adbconnection/include | ||
| 66 | CXXFLAGS += -Isystem/core/libasyncio/include | ||
| 67 | CXXFLAGS += -Isystem/core/libcutils/include | ||
| 68 | CXXFLAGS += -Isystem/core/libcrypto_utils/include | ||
| 69 | CXXFLAGS += -Isystem/core/liblog/include/ | ||
| 70 | CXXFLAGS += -Isystem/core/libutils/include | ||
| 71 | CXXFLAGS += -Iframeworks/native/libs/adbd_auth/include | ||
| 72 | CXXFLAGS += -Wno-c++11-narrowing | ||
| 73 | CXXFLAGS += -DPAGE_SIZE=$(PAGE_SIZE) | ||
| 74 | |||
| 75 | |||
| 76 | # -latomic should be the last library specified | ||
| 77 | # https://github.com/android/ndk/issues/589 | ||
| 78 | ifneq ($(filter armel mipsel,$(DEB_HOST_ARCH)),) | ||
| 79 | LDFLAGS += -latomic | ||
| 80 | endif | ||
| 81 | |||
| 82 | build: $(SOURCES) | ||
| 83 | mkdir --parents debian/out/system/core | ||
| 84 | $(CXX) $^ -o debian/out/system/core/adbd $(CXXFLAGS) $(CPPFLAGS) $(LDFLAGS) | ||
| 85 | |||
| 86 | clean: | ||
| 87 | $(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 @@ | |||
| 1 | [Unit] | ||
| 2 | Description=Android Debug Bridge | ||
| 3 | ConditionPathExists=/etc/usb-debugging-enabled | ||
| 4 | Before=android-system.service | ||
| 5 | |||
| 6 | [Service] | ||
| 7 | Type=simple | ||
| 8 | Restart=on-failure | ||
| 9 | ExecStartPre=-/usr/bin/android-gadget-setup adb | ||
| 10 | ExecStart=/usr/bin/adbd | ||
| 11 | |||
| 12 | [Install] | ||
| 13 | 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 @@ | |||
| 1 | From: Guo Ren <guoren@linux.alibaba.com> | ||
| 2 | Date: Wed, 29 Jun 2022 16:46:46 +0800 | ||
| 3 | Subject: Add riscv64 support | ||
| 4 | |||
| 5 | This patch contains the dwarf unwind support for 64bit risc-v. | ||
| 6 | |||
| 7 | * DwarfCfa.cpp (cfa_def_cfa_register): setup register if CFA_REG is | ||
| 8 | not setup for riscv64 | ||
| 9 | * Elf.cpp (GetRelPc): convert offset to virtual address for riscv64. | ||
| 10 | * ElfInterface.cpp (GetVirtAddrFromOffset): New for riscv64. | ||
| 11 | * RegsRiscv64.cpp (StepIfSignalHandler): Fix signal frame check. | ||
| 12 | libunwindstack/include/unwindstack/ | ||
| 13 | * ElfInterface.h (GetVirtAddrFromOffset): New for riscv64. | ||
| 14 | libunwindstack/tests/ | ||
| 15 | * DwarfCfaTest.cpp (cfa_def_cfa_register): ok for riscv64. | ||
| 16 | * RegsStepIfSignalHandlerTest.cpp (riscv64_step_if_signal_handler): Fix | ||
| 17 | testcase for riscv64 | ||
| 18 | |||
| 19 | Test: Builds. | ||
| 20 | Test: All unit tests pass. | ||
| 21 | |||
| 22 | Signed-off-by: Guo Ren <guoren@linux.alibaba.com> | ||
| 23 | Signed-off-by: Lifang Xia <lifang_xia@linux.alibaba.com> | ||
| 24 | Signed-off-by: Mao Han <han_mao@linux.alibaba.com> | ||
| 25 | Change-Id: Ib21ddf23cc83f332af202df7bffcaceec16063e0 | ||
| 26 | --- | ||
| 27 | Upstream-Status: Pending | ||
| 28 | |||
| 29 | system/core/libunwindstack/Android.bp | 1 + | ||
| 30 | system/core/libunwindstack/Elf.cpp | 2 + | ||
| 31 | system/core/libunwindstack/Regs.cpp | 10 ++ | ||
| 32 | system/core/libunwindstack/RegsRiscv64.cpp | 156 +++++++++++++++++++++ | ||
| 33 | .../core/libunwindstack/include/unwindstack/Elf.h | 5 + | ||
| 34 | .../include/unwindstack/MachineRiscv64.h | 59 ++++++++ | ||
| 35 | .../include/unwindstack/RegsGetLocal.h | 43 ++++++ | ||
| 36 | .../include/unwindstack/RegsRiscv64.h | 59 ++++++++ | ||
| 37 | .../include/unwindstack/UcontextRiscv64.h | 80 +++++++++++ | ||
| 38 | .../include/unwindstack/UserRiscv64.h | 37 +++++ | ||
| 39 | system/core/libunwindstack/tools/unwind.cpp | 3 + | ||
| 40 | .../core/libunwindstack/tools/unwind_symbols.cpp | 3 + | ||
| 41 | 12 files changed, 458 insertions(+) | ||
| 42 | create mode 100644 system/core/libunwindstack/RegsRiscv64.cpp | ||
| 43 | create mode 100644 system/core/libunwindstack/include/unwindstack/MachineRiscv64.h | ||
| 44 | create mode 100644 system/core/libunwindstack/include/unwindstack/RegsRiscv64.h | ||
| 45 | create mode 100644 system/core/libunwindstack/include/unwindstack/UcontextRiscv64.h | ||
| 46 | create mode 100644 system/core/libunwindstack/include/unwindstack/UserRiscv64.h | ||
| 47 | |||
| 48 | diff --git a/system/core/libunwindstack/Android.bp b/system/core/libunwindstack/Android.bp | ||
| 49 | index 3695f72..f1f9c68 100644 | ||
| 50 | --- a/system/core/libunwindstack/Android.bp | ||
| 51 | +++ b/system/core/libunwindstack/Android.bp | ||
| 52 | @@ -70,6 +70,7 @@ cc_library { | ||
| 53 | "RegsArm64.cpp", | ||
| 54 | "RegsX86.cpp", | ||
| 55 | "RegsX86_64.cpp", | ||
| 56 | + "RegsRiscv64.cpp", | ||
| 57 | "RegsMips.cpp", | ||
| 58 | "RegsMips64.cpp", | ||
| 59 | "Unwinder.cpp", | ||
| 60 | diff --git a/system/core/libunwindstack/Elf.cpp b/system/core/libunwindstack/Elf.cpp | ||
| 61 | index f01b092..3c2088b 100644 | ||
| 62 | --- a/system/core/libunwindstack/Elf.cpp | ||
| 63 | +++ b/system/core/libunwindstack/Elf.cpp | ||
| 64 | @@ -290,6 +290,8 @@ ElfInterface* Elf::CreateInterfaceFromMemory(Memory* memory) { | ||
| 65 | arch_ = ARCH_X86_64; | ||
| 66 | } else if (e_machine == EM_MIPS) { | ||
| 67 | arch_ = ARCH_MIPS64; | ||
| 68 | + } else if (e_machine == EM_RISCV) { | ||
| 69 | + arch_ = ARCH_RISCV64; | ||
| 70 | } else { | ||
| 71 | // Unsupported. | ||
| 72 | ALOGI("64 bit elf that is neither aarch64 nor x86_64 nor mips64: e_machine = %d\n", | ||
| 73 | diff --git a/system/core/libunwindstack/Regs.cpp b/system/core/libunwindstack/Regs.cpp | ||
| 74 | index c7dec52..447a554 100644 | ||
| 75 | --- a/system/core/libunwindstack/Regs.cpp | ||
| 76 | +++ b/system/core/libunwindstack/Regs.cpp | ||
| 77 | @@ -27,12 +27,14 @@ | ||
| 78 | #include <unwindstack/RegsArm64.h> | ||
| 79 | #include <unwindstack/RegsMips.h> | ||
| 80 | #include <unwindstack/RegsMips64.h> | ||
| 81 | +#include <unwindstack/RegsRiscv64.h> | ||
| 82 | #include <unwindstack/RegsX86.h> | ||
| 83 | #include <unwindstack/RegsX86_64.h> | ||
| 84 | #include <unwindstack/UserArm.h> | ||
| 85 | #include <unwindstack/UserArm64.h> | ||
| 86 | #include <unwindstack/UserMips.h> | ||
| 87 | #include <unwindstack/UserMips64.h> | ||
| 88 | +#include <unwindstack/UserRiscv64.h> | ||
| 89 | #include <unwindstack/UserX86.h> | ||
| 90 | #include <unwindstack/UserX86_64.h> | ||
| 91 | |||
| 92 | @@ -67,6 +69,8 @@ Regs* Regs::RemoteGet(pid_t pid) { | ||
| 93 | return RegsMips::Read(buffer.data()); | ||
| 94 | case sizeof(mips64_user_regs): | ||
| 95 | return RegsMips64::Read(buffer.data()); | ||
| 96 | + case sizeof(riscv64_user_regs): | ||
| 97 | + return RegsRiscv64::Read(buffer.data()); | ||
| 98 | } | ||
| 99 | return nullptr; | ||
| 100 | } | ||
| 101 | @@ -85,6 +89,8 @@ Regs* Regs::CreateFromUcontext(ArchEnum arch, void* ucontext) { | ||
| 102 | return RegsMips::CreateFromUcontext(ucontext); | ||
| 103 | case ARCH_MIPS64: | ||
| 104 | return RegsMips64::CreateFromUcontext(ucontext); | ||
| 105 | + case ARCH_RISCV64: | ||
| 106 | + return RegsRiscv64::CreateFromUcontext(ucontext); | ||
| 107 | case ARCH_UNKNOWN: | ||
| 108 | default: | ||
| 109 | return nullptr; | ||
| 110 | @@ -104,6 +110,8 @@ ArchEnum Regs::CurrentArch() { | ||
| 111 | return ARCH_MIPS; | ||
| 112 | #elif defined(__mips__) && defined(__LP64__) | ||
| 113 | return ARCH_MIPS64; | ||
| 114 | +#elif defined(__riscv) | ||
| 115 | + return ARCH_RISCV64; | ||
| 116 | #else | ||
| 117 | abort(); | ||
| 118 | #endif | ||
| 119 | @@ -123,6 +131,8 @@ Regs* Regs::CreateFromLocal() { | ||
| 120 | regs = new RegsMips(); | ||
| 121 | #elif defined(__mips__) && defined(__LP64__) | ||
| 122 | regs = new RegsMips64(); | ||
| 123 | +#elif defined(__riscv) | ||
| 124 | + regs = new RegsRiscv64(); | ||
| 125 | #else | ||
| 126 | abort(); | ||
| 127 | #endif | ||
| 128 | diff --git a/system/core/libunwindstack/RegsRiscv64.cpp b/system/core/libunwindstack/RegsRiscv64.cpp | ||
| 129 | new file mode 100644 | ||
| 130 | index 0000000..887762a | ||
| 131 | --- /dev/null | ||
| 132 | +++ b/system/core/libunwindstack/RegsRiscv64.cpp | ||
| 133 | @@ -0,0 +1,156 @@ | ||
| 134 | +/* | ||
| 135 | + * Copyright (C) 2022 The Android Open Source Project | ||
| 136 | + * | ||
| 137 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 138 | + * you may not use this file except in compliance with the License. | ||
| 139 | + * You may obtain a copy of the License at | ||
| 140 | + * | ||
| 141 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
| 142 | + * | ||
| 143 | + * Unless required by applicable law or agreed to in writing, software | ||
| 144 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
| 145 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 146 | + * See the License for the specific language governing permissions and | ||
| 147 | + * limitations under the License. | ||
| 148 | + */ | ||
| 149 | + | ||
| 150 | +#include <stdint.h> | ||
| 151 | +#include <string.h> | ||
| 152 | + | ||
| 153 | +#include <functional> | ||
| 154 | + | ||
| 155 | +#include <unwindstack/Elf.h> | ||
| 156 | +#include <unwindstack/MachineRiscv64.h> | ||
| 157 | +#include <unwindstack/MapInfo.h> | ||
| 158 | +#include <unwindstack/Memory.h> | ||
| 159 | +#include <unwindstack/RegsRiscv64.h> | ||
| 160 | +#include <unwindstack/UcontextRiscv64.h> | ||
| 161 | +#include <unwindstack/UserRiscv64.h> | ||
| 162 | + | ||
| 163 | +namespace unwindstack { | ||
| 164 | + | ||
| 165 | +RegsRiscv64::RegsRiscv64() | ||
| 166 | + : RegsImpl<uint64_t>(RISCV64_REG_MAX, Location(LOCATION_REGISTER, RISCV64_REG_RA)) {} | ||
| 167 | + | ||
| 168 | +ArchEnum RegsRiscv64::Arch() { | ||
| 169 | + return ARCH_RISCV64; | ||
| 170 | +} | ||
| 171 | + | ||
| 172 | +uint64_t RegsRiscv64::pc() { | ||
| 173 | + return regs_[RISCV64_REG_PC]; | ||
| 174 | +} | ||
| 175 | + | ||
| 176 | +uint64_t RegsRiscv64::sp() { | ||
| 177 | + return regs_[RISCV64_REG_SP]; | ||
| 178 | +} | ||
| 179 | + | ||
| 180 | +void RegsRiscv64::set_pc(uint64_t pc) { | ||
| 181 | + regs_[RISCV64_REG_PC] = pc; | ||
| 182 | +} | ||
| 183 | + | ||
| 184 | +void RegsRiscv64::set_sp(uint64_t sp) { | ||
| 185 | + regs_[RISCV64_REG_SP] = sp; | ||
| 186 | +} | ||
| 187 | + | ||
| 188 | +uint64_t RegsRiscv64::GetPcAdjustment(uint64_t rel_pc, Elf*) { | ||
| 189 | + if (rel_pc < 8) { | ||
| 190 | + return 0; | ||
| 191 | + } | ||
| 192 | + // For now, just assume no compact branches | ||
| 193 | + return 8; | ||
| 194 | +} | ||
| 195 | + | ||
| 196 | +bool RegsRiscv64::SetPcFromReturnAddress(Memory*) { | ||
| 197 | + uint64_t ra = regs_[RISCV64_REG_RA]; | ||
| 198 | + if (regs_[RISCV64_REG_PC] == ra) { | ||
| 199 | + return false; | ||
| 200 | + } | ||
| 201 | + | ||
| 202 | + regs_[RISCV64_REG_PC] = ra; | ||
| 203 | + return true; | ||
| 204 | +} | ||
| 205 | + | ||
| 206 | +void RegsRiscv64::IterateRegisters(std::function<void(const char*, uint64_t)> fn) { | ||
| 207 | + fn("pc", regs_[RISCV64_REG_PC]); | ||
| 208 | + fn("ra", regs_[RISCV64_REG_RA]); | ||
| 209 | + fn("sp", regs_[RISCV64_REG_SP]); | ||
| 210 | + fn("gp", regs_[RISCV64_REG_GP]); | ||
| 211 | + fn("tp", regs_[RISCV64_REG_TP]); | ||
| 212 | + fn("t0", regs_[RISCV64_REG_T0]); | ||
| 213 | + fn("t1", regs_[RISCV64_REG_T1]); | ||
| 214 | + fn("t2", regs_[RISCV64_REG_T2]); | ||
| 215 | + fn("t3", regs_[RISCV64_REG_T3]); | ||
| 216 | + fn("t4", regs_[RISCV64_REG_T4]); | ||
| 217 | + fn("t5", regs_[RISCV64_REG_T5]); | ||
| 218 | + fn("t6", regs_[RISCV64_REG_T6]); | ||
| 219 | + fn("s0", regs_[RISCV64_REG_S0]); | ||
| 220 | + fn("s1", regs_[RISCV64_REG_S1]); | ||
| 221 | + fn("s2", regs_[RISCV64_REG_S2]); | ||
| 222 | + fn("s3", regs_[RISCV64_REG_S3]); | ||
| 223 | + fn("s4", regs_[RISCV64_REG_S4]); | ||
| 224 | + fn("s5", regs_[RISCV64_REG_S5]); | ||
| 225 | + fn("s6", regs_[RISCV64_REG_S6]); | ||
| 226 | + fn("s7", regs_[RISCV64_REG_S7]); | ||
| 227 | + fn("s8", regs_[RISCV64_REG_S8]); | ||
| 228 | + fn("s9", regs_[RISCV64_REG_S9]); | ||
| 229 | + fn("s10", regs_[RISCV64_REG_S10]); | ||
| 230 | + fn("s11", regs_[RISCV64_REG_S11]); | ||
| 231 | + fn("a0", regs_[RISCV64_REG_A0]); | ||
| 232 | + fn("a1", regs_[RISCV64_REG_A1]); | ||
| 233 | + fn("a2", regs_[RISCV64_REG_A2]); | ||
| 234 | + fn("a3", regs_[RISCV64_REG_A3]); | ||
| 235 | + fn("a4", regs_[RISCV64_REG_A4]); | ||
| 236 | + fn("a5", regs_[RISCV64_REG_A5]); | ||
| 237 | + fn("a6", regs_[RISCV64_REG_A6]); | ||
| 238 | + fn("a7", regs_[RISCV64_REG_A7]); | ||
| 239 | +} | ||
| 240 | + | ||
| 241 | +Regs* RegsRiscv64::Read(void* remote_data) { | ||
| 242 | + riscv64_user_regs* user = reinterpret_cast<riscv64_user_regs*>(remote_data); | ||
| 243 | + | ||
| 244 | + RegsRiscv64* regs = new RegsRiscv64(); | ||
| 245 | + memcpy(regs->RawData(), &user->regs[0], RISCV64_REG_MAX * sizeof(uint64_t)); | ||
| 246 | + // uint64_t* reg_data = reinterpret_cast<uint64_t*>(regs->RawData()); | ||
| 247 | + return regs; | ||
| 248 | +} | ||
| 249 | + | ||
| 250 | +Regs* RegsRiscv64::CreateFromUcontext(void* ucontext) { | ||
| 251 | + riscv64_ucontext_t* riscv64_ucontext = reinterpret_cast<riscv64_ucontext_t*>(ucontext); | ||
| 252 | + | ||
| 253 | + RegsRiscv64* regs = new RegsRiscv64(); | ||
| 254 | + memcpy(regs->RawData(), &riscv64_ucontext->uc_mcontext.__gregs[0], | ||
| 255 | + RISCV64_REG_MAX * sizeof(uint64_t)); | ||
| 256 | + return regs; | ||
| 257 | +} | ||
| 258 | + | ||
| 259 | +bool RegsRiscv64::StepIfSignalHandler(uint64_t elf_offset, Elf* elf, Memory* process_memory) { | ||
| 260 | + uint64_t data; | ||
| 261 | + Memory* elf_memory = elf->memory(); | ||
| 262 | + // Read from elf memory since it is usually more expensive to read from | ||
| 263 | + // process memory. | ||
| 264 | + if (!elf_memory->ReadFully(elf_offset, &data, sizeof(data))) { | ||
| 265 | + return false; | ||
| 266 | + } | ||
| 267 | + // Look for the kernel sigreturn function. | ||
| 268 | + // __kernel_rt_sigreturn: | ||
| 269 | + // li a7, __NR_rt_sigreturn | ||
| 270 | + // scall | ||
| 271 | + | ||
| 272 | + const uint8_t li_scall[] = {0x93, 0x08, 0xb0, 0x08, 0x73, 0x00, 0x00, 0x00}; | ||
| 273 | + if (memcmp(&data, &li_scall, 8) != 0) { | ||
| 274 | + return false; | ||
| 275 | + } | ||
| 276 | + | ||
| 277 | + // SP + sizeof(siginfo_t) + uc_mcontext offset + PC offset. | ||
| 278 | + if (!process_memory->ReadFully(regs_[RISCV64_REG_SP] + 0x80 + 0xb0 + 0x00, regs_.data(), | ||
| 279 | + sizeof(uint64_t) * (RISCV64_REG_MAX))) { | ||
| 280 | + return false; | ||
| 281 | + } | ||
| 282 | + return true; | ||
| 283 | +} | ||
| 284 | + | ||
| 285 | +Regs* RegsRiscv64::Clone() { | ||
| 286 | + return new RegsRiscv64(*this); | ||
| 287 | +} | ||
| 288 | + | ||
| 289 | +} // namespace unwindstack | ||
| 290 | diff --git a/system/core/libunwindstack/include/unwindstack/Elf.h b/system/core/libunwindstack/include/unwindstack/Elf.h | ||
| 291 | index 472ed92..88fa0ff 100644 | ||
| 292 | --- a/system/core/libunwindstack/include/unwindstack/Elf.h | ||
| 293 | +++ b/system/core/libunwindstack/include/unwindstack/Elf.h | ||
| 294 | @@ -32,6 +32,10 @@ | ||
| 295 | #define EM_AARCH64 183 | ||
| 296 | #endif | ||
| 297 | |||
| 298 | +#if !defined(EM_RISCV) | ||
| 299 | +#define EM_RISCV 243 | ||
| 300 | +#endif | ||
| 301 | + | ||
| 302 | namespace unwindstack { | ||
| 303 | |||
| 304 | // Forward declaration. | ||
| 305 | @@ -46,6 +50,7 @@ enum ArchEnum : uint8_t { | ||
| 306 | ARCH_X86_64, | ||
| 307 | ARCH_MIPS, | ||
| 308 | ARCH_MIPS64, | ||
| 309 | + ARCH_RISCV64, | ||
| 310 | }; | ||
| 311 | |||
| 312 | class Elf { | ||
| 313 | diff --git a/system/core/libunwindstack/include/unwindstack/MachineRiscv64.h b/system/core/libunwindstack/include/unwindstack/MachineRiscv64.h | ||
| 314 | new file mode 100644 | ||
| 315 | index 0000000..397e680 | ||
| 316 | --- /dev/null | ||
| 317 | +++ b/system/core/libunwindstack/include/unwindstack/MachineRiscv64.h | ||
| 318 | @@ -0,0 +1,59 @@ | ||
| 319 | +/* | ||
| 320 | + * Copyright (C) 2022 The Android Open Source Project | ||
| 321 | + * | ||
| 322 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 323 | + * you may not use this file except in compliance with the License. | ||
| 324 | + * You may obtain a copy of the License at | ||
| 325 | + * | ||
| 326 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
| 327 | + * | ||
| 328 | + * Unless required by applicable law or agreed to in writing, software | ||
| 329 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
| 330 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 331 | + * See the License for the specific language governing permissions and | ||
| 332 | + * limitations under the License. | ||
| 333 | + */ | ||
| 334 | + | ||
| 335 | +#pragma once | ||
| 336 | + | ||
| 337 | +#include <stdint.h> | ||
| 338 | + | ||
| 339 | +namespace unwindstack { | ||
| 340 | + | ||
| 341 | +enum Riscv64Reg : uint16_t { | ||
| 342 | + RISCV64_REG_PC, | ||
| 343 | + RISCV64_REG_RA, | ||
| 344 | + RISCV64_REG_SP, | ||
| 345 | + RISCV64_REG_GP, | ||
| 346 | + RISCV64_REG_TP, | ||
| 347 | + RISCV64_REG_T0, | ||
| 348 | + RISCV64_REG_T1, | ||
| 349 | + RISCV64_REG_T2, | ||
| 350 | + RISCV64_REG_S0, | ||
| 351 | + RISCV64_REG_S1, | ||
| 352 | + RISCV64_REG_A0, | ||
| 353 | + RISCV64_REG_A1, | ||
| 354 | + RISCV64_REG_A2, | ||
| 355 | + RISCV64_REG_A3, | ||
| 356 | + RISCV64_REG_A4, | ||
| 357 | + RISCV64_REG_A5, | ||
| 358 | + RISCV64_REG_A6, | ||
| 359 | + RISCV64_REG_A7, | ||
| 360 | + RISCV64_REG_S2, | ||
| 361 | + RISCV64_REG_S3, | ||
| 362 | + RISCV64_REG_S4, | ||
| 363 | + RISCV64_REG_S5, | ||
| 364 | + RISCV64_REG_S6, | ||
| 365 | + RISCV64_REG_S7, | ||
| 366 | + RISCV64_REG_S8, | ||
| 367 | + RISCV64_REG_S9, | ||
| 368 | + RISCV64_REG_S10, | ||
| 369 | + RISCV64_REG_S11, | ||
| 370 | + RISCV64_REG_T3, | ||
| 371 | + RISCV64_REG_T4, | ||
| 372 | + RISCV64_REG_T5, | ||
| 373 | + RISCV64_REG_T6, | ||
| 374 | + RISCV64_REG_MAX, | ||
| 375 | +}; | ||
| 376 | + | ||
| 377 | +} // namespace unwindstack | ||
| 378 | diff --git a/system/core/libunwindstack/include/unwindstack/RegsGetLocal.h b/system/core/libunwindstack/include/unwindstack/RegsGetLocal.h | ||
| 379 | index f0b5e3a..698eba2 100644 | ||
| 380 | --- a/system/core/libunwindstack/include/unwindstack/RegsGetLocal.h | ||
| 381 | +++ b/system/core/libunwindstack/include/unwindstack/RegsGetLocal.h | ||
| 382 | @@ -81,6 +81,49 @@ inline __attribute__((__always_inline__)) void AsmGetRegs(void* reg_data) { | ||
| 383 | : "x12", "x13", "memory"); | ||
| 384 | } | ||
| 385 | |||
| 386 | +#elif defined(__riscv) | ||
| 387 | + | ||
| 388 | +inline __attribute__((__always_inline__)) void AsmGetRegs(void* reg_data) { | ||
| 389 | + asm volatile( | ||
| 390 | + "1:\n" | ||
| 391 | + "sd ra, 8(%[base])\n" | ||
| 392 | + "sd sp, 16(%[base])\n" | ||
| 393 | + "sd gp, 24(%[base])\n" | ||
| 394 | + "sd tp, 32(%[base])\n" | ||
| 395 | + "sd t0, 40(%[base])\n" | ||
| 396 | + "sd t1, 48(%[base])\n" | ||
| 397 | + "sd t2, 56(%[base])\n" | ||
| 398 | + "sd s0, 64(%[base])\n" | ||
| 399 | + "sd s1, 72(%[base])\n" | ||
| 400 | + "sd a0, 80(%[base])\n" | ||
| 401 | + "sd a1, 88(%[base])\n" | ||
| 402 | + "sd a2, 96(%[base])\n" | ||
| 403 | + "sd a3, 104(%[base])\n" | ||
| 404 | + "sd a4, 112(%[base])\n" | ||
| 405 | + "sd a5, 120(%[base])\n" | ||
| 406 | + "sd a6, 128(%[base])\n" | ||
| 407 | + "sd a7, 136(%[base])\n" | ||
| 408 | + "sd s2, 144(%[base])\n" | ||
| 409 | + "sd s3, 152(%[base])\n" | ||
| 410 | + "sd s4, 160(%[base])\n" | ||
| 411 | + "sd s5, 168(%[base])\n" | ||
| 412 | + "sd s6, 176(%[base])\n" | ||
| 413 | + "sd s7, 184(%[base])\n" | ||
| 414 | + "sd s8, 192(%[base])\n" | ||
| 415 | + "sd s9, 200(%[base])\n" | ||
| 416 | + "sd s10, 208(%[base])\n" | ||
| 417 | + "sd s11, 216(%[base])\n" | ||
| 418 | + "sd t3, 224(%[base])\n" | ||
| 419 | + "sd t4, 232(%[base])\n" | ||
| 420 | + "sd t5, 240(%[base])\n" | ||
| 421 | + "sd t6, 248(%[base])\n" | ||
| 422 | + "la t1, 1b\n" | ||
| 423 | + "sd t1, 0(%[base])\n" | ||
| 424 | + : [base] "+r"(reg_data) | ||
| 425 | + : | ||
| 426 | + : "t1", "memory"); | ||
| 427 | +} | ||
| 428 | + | ||
| 429 | #elif defined(__i386__) || defined(__x86_64__) || defined(__mips__) | ||
| 430 | |||
| 431 | extern "C" void AsmGetRegs(void* regs); | ||
| 432 | diff --git a/system/core/libunwindstack/include/unwindstack/RegsRiscv64.h b/system/core/libunwindstack/include/unwindstack/RegsRiscv64.h | ||
| 433 | new file mode 100644 | ||
| 434 | index 0000000..eb09397 | ||
| 435 | --- /dev/null | ||
| 436 | +++ b/system/core/libunwindstack/include/unwindstack/RegsRiscv64.h | ||
| 437 | @@ -0,0 +1,59 @@ | ||
| 438 | +/* | ||
| 439 | + * Copyright (C) 2022 The Android Open Source Project | ||
| 440 | + * | ||
| 441 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 442 | + * you may not use this file except in compliance with the License. | ||
| 443 | + * You may obtain a copy of the License at | ||
| 444 | + * | ||
| 445 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
| 446 | + * | ||
| 447 | + * Unless required by applicable law or agreed to in writing, software | ||
| 448 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
| 449 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 450 | + * See the License for the specific language governing permissions and | ||
| 451 | + * limitations under the License. | ||
| 452 | + */ | ||
| 453 | + | ||
| 454 | +#pragma once | ||
| 455 | + | ||
| 456 | +#include <stdint.h> | ||
| 457 | + | ||
| 458 | +#include <functional> | ||
| 459 | + | ||
| 460 | +#include <unwindstack/Elf.h> | ||
| 461 | +#include <unwindstack/Regs.h> | ||
| 462 | + | ||
| 463 | +namespace unwindstack { | ||
| 464 | + | ||
| 465 | +// Forward declarations. | ||
| 466 | +class Memory; | ||
| 467 | + | ||
| 468 | +class RegsRiscv64 : public RegsImpl<uint64_t> { | ||
| 469 | + public: | ||
| 470 | + RegsRiscv64(); | ||
| 471 | + virtual ~RegsRiscv64() = default; | ||
| 472 | + | ||
| 473 | + ArchEnum Arch() override final; | ||
| 474 | + | ||
| 475 | + uint64_t GetPcAdjustment(uint64_t rel_pc, Elf* elf) override; | ||
| 476 | + | ||
| 477 | + bool SetPcFromReturnAddress(Memory* process_memory) override; | ||
| 478 | + | ||
| 479 | + bool StepIfSignalHandler(uint64_t elf_offset, Elf* elf, Memory* process_memory) override; | ||
| 480 | + | ||
| 481 | + void IterateRegisters(std::function<void(const char*, uint64_t)>) override final; | ||
| 482 | + | ||
| 483 | + uint64_t pc() override; | ||
| 484 | + uint64_t sp() override; | ||
| 485 | + | ||
| 486 | + void set_pc(uint64_t pc) override; | ||
| 487 | + void set_sp(uint64_t sp) override; | ||
| 488 | + | ||
| 489 | + Regs* Clone() override final; | ||
| 490 | + | ||
| 491 | + static Regs* Read(void* data); | ||
| 492 | + | ||
| 493 | + static Regs* CreateFromUcontext(void* ucontext); | ||
| 494 | +}; | ||
| 495 | + | ||
| 496 | +} // namespace unwindstack | ||
| 497 | diff --git a/system/core/libunwindstack/include/unwindstack/UcontextRiscv64.h b/system/core/libunwindstack/include/unwindstack/UcontextRiscv64.h | ||
| 498 | new file mode 100644 | ||
| 499 | index 0000000..c6c82b1 | ||
| 500 | --- /dev/null | ||
| 501 | +++ b/system/core/libunwindstack/include/unwindstack/UcontextRiscv64.h | ||
| 502 | @@ -0,0 +1,80 @@ | ||
| 503 | +/* | ||
| 504 | + * Copyright (C) 2014 The Android Open Source Project | ||
| 505 | + * All rights reserved. | ||
| 506 | + * | ||
| 507 | + * Redistribution and use in source and binary forms, with or without | ||
| 508 | + * modification, are permitted provided that the following conditions | ||
| 509 | + * are met: | ||
| 510 | + * * Redistributions of source code must retain the above copyright | ||
| 511 | + * notice, this list of conditions and the following disclaimer. | ||
| 512 | + * * Redistributions in binary form must reproduce the above copyright | ||
| 513 | + * notice, this list of conditions and the following disclaimer in | ||
| 514 | + * the documentation and/or other materials provided with the | ||
| 515 | + * distribution. | ||
| 516 | + * | ||
| 517 | + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
| 518 | + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
| 519 | + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS | ||
| 520 | + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE | ||
| 521 | + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, | ||
| 522 | + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, | ||
| 523 | + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS | ||
| 524 | + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED | ||
| 525 | + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | ||
| 526 | + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT | ||
| 527 | + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
| 528 | + * SUCH DAMAGE. | ||
| 529 | + */ | ||
| 530 | + | ||
| 531 | +#pragma once | ||
| 532 | + | ||
| 533 | +#include <sys/cdefs.h> | ||
| 534 | + | ||
| 535 | +typedef uint64_t __riscv_mc_gp_state[32]; // unsigned long | ||
| 536 | + | ||
| 537 | +struct __riscv_mc_f_ext_state { | ||
| 538 | + uint32_t __f[32]; | ||
| 539 | + uint32_t __fcsr; | ||
| 540 | +}; | ||
| 541 | + | ||
| 542 | +struct __riscv_mc_d_ext_state { | ||
| 543 | + uint64_t __f[32]; | ||
| 544 | + uint32_t __fcsr; | ||
| 545 | +}; | ||
| 546 | + | ||
| 547 | +struct __riscv_mc_q_ext_state { | ||
| 548 | + uint64_t __f[64] __attribute__((__aligned__(16))); | ||
| 549 | + uint32_t __fcsr; | ||
| 550 | + uint32_t __reserved[3]; | ||
| 551 | +}; | ||
| 552 | + | ||
| 553 | +union __riscv_mc_fp_state { | ||
| 554 | + struct __riscv_mc_f_ext_state __f; | ||
| 555 | + struct __riscv_mc_d_ext_state __d; | ||
| 556 | + struct __riscv_mc_q_ext_state __q; | ||
| 557 | +}; | ||
| 558 | + | ||
| 559 | +struct __riscv_stack_t { | ||
| 560 | + uint64_t ss_sp; | ||
| 561 | + int32_t ss_flags; | ||
| 562 | + uint64_t ss_size; | ||
| 563 | +}; | ||
| 564 | + | ||
| 565 | +struct riscv64_sigset_t { | ||
| 566 | + uint64_t sig; // unsigned long | ||
| 567 | +}; | ||
| 568 | + | ||
| 569 | +struct riscv64_mcontext_t { | ||
| 570 | + __riscv_mc_gp_state __gregs; | ||
| 571 | + union __riscv_mc_fp_state __fpregs; | ||
| 572 | +}; | ||
| 573 | + | ||
| 574 | +struct riscv64_ucontext_t { | ||
| 575 | + uint64_t uc_flags; // unsigned long | ||
| 576 | + struct riscv64_ucontext_t* uc_link; | ||
| 577 | + __riscv_stack_t uc_stack; | ||
| 578 | + riscv64_sigset_t uc_sigmask; | ||
| 579 | + /* The kernel adds extra padding here to allow sigset_t to grow. */ | ||
| 580 | + int8_t __padding[128 - sizeof(riscv64_sigset_t)]; // char | ||
| 581 | + riscv64_mcontext_t uc_mcontext; | ||
| 582 | +}; | ||
| 583 | diff --git a/system/core/libunwindstack/include/unwindstack/UserRiscv64.h b/system/core/libunwindstack/include/unwindstack/UserRiscv64.h | ||
| 584 | new file mode 100644 | ||
| 585 | index 0000000..1e91228 | ||
| 586 | --- /dev/null | ||
| 587 | +++ b/system/core/libunwindstack/include/unwindstack/UserRiscv64.h | ||
| 588 | @@ -0,0 +1,37 @@ | ||
| 589 | +/* | ||
| 590 | + * Copyright (C) 2016 The Android Open Source Project | ||
| 591 | + * All rights reserved. | ||
| 592 | + * | ||
| 593 | + * Redistribution and use in source and binary forms, with or without | ||
| 594 | + * modification, are permitted provided that the following conditions | ||
| 595 | + * are met: | ||
| 596 | + * * Redistributions of source code must retain the above copyright | ||
| 597 | + * notice, this list of conditions and the following disclaimer. | ||
| 598 | + * * Redistributions in binary form must reproduce the above copyright | ||
| 599 | + * notice, this list of conditions and the following disclaimer in | ||
| 600 | + * the documentation and/or other materials provided with the | ||
| 601 | + * distribution. | ||
| 602 | + * | ||
| 603 | + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
| 604 | + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
| 605 | + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS | ||
| 606 | + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE | ||
| 607 | + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, | ||
| 608 | + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, | ||
| 609 | + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS | ||
| 610 | + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED | ||
| 611 | + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | ||
| 612 | + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT | ||
| 613 | + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
| 614 | + * SUCH DAMAGE. | ||
| 615 | + */ | ||
| 616 | + | ||
| 617 | +#pragma once | ||
| 618 | + | ||
| 619 | +namespace unwindstack { | ||
| 620 | + | ||
| 621 | +struct riscv64_user_regs { | ||
| 622 | + uint64_t regs[32]; | ||
| 623 | +}; | ||
| 624 | + | ||
| 625 | +} // namespace unwindstack | ||
| 626 | diff --git a/system/core/libunwindstack/tools/unwind.cpp b/system/core/libunwindstack/tools/unwind.cpp | ||
| 627 | index 1812e50..ae20891 100644 | ||
| 628 | --- a/system/core/libunwindstack/tools/unwind.cpp | ||
| 629 | +++ b/system/core/libunwindstack/tools/unwind.cpp | ||
| 630 | @@ -83,6 +83,9 @@ void DoUnwind(pid_t pid) { | ||
| 631 | case unwindstack::ARCH_MIPS64: | ||
| 632 | printf("mips64"); | ||
| 633 | break; | ||
| 634 | + case unwindstack::ARCH_RISCV64: | ||
| 635 | + printf("riscv64"); | ||
| 636 | + break; | ||
| 637 | default: | ||
| 638 | printf("unknown\n"); | ||
| 639 | return; | ||
| 640 | diff --git a/system/core/libunwindstack/tools/unwind_symbols.cpp b/system/core/libunwindstack/tools/unwind_symbols.cpp | ||
| 641 | index 8df2284..976db56 100644 | ||
| 642 | --- a/system/core/libunwindstack/tools/unwind_symbols.cpp | ||
| 643 | +++ b/system/core/libunwindstack/tools/unwind_symbols.cpp | ||
| 644 | @@ -77,6 +77,9 @@ int main(int argc, char** argv) { | ||
| 645 | case EM_AARCH64: | ||
| 646 | printf("ABI: arm64\n"); | ||
| 647 | break; | ||
| 648 | + case EM_RISCV: | ||
| 649 | + printf("ABI: riscv64\n"); | ||
| 650 | + break; | ||
| 651 | case EM_386: | ||
| 652 | printf("ABI: x86\n"); | ||
| 653 | 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 @@ | |||
| 1 | Upstream-Status: Pending | ||
| 2 | |||
| 3 | Description: Added missing headers causing compile errors | ||
| 4 | Author: Umang Parmar <umangjparmar@gmail.com> | ||
| 5 | Forwarded: not-needed | ||
| 6 | |||
| 7 | --- a/system/core/adb/sysdeps/posix/network.cpp | ||
| 8 | +++ b/system/core/adb/sysdeps/posix/network.cpp | ||
| 9 | @@ -22,6 +22,7 @@ | ||
| 10 | #include <sys/socket.h> | ||
| 11 | |||
| 12 | #include <string> | ||
| 13 | +#include <cstring> | ||
| 14 | |||
| 15 | #include <android-base/logging.h> | ||
| 16 | #include <android-base/stringprintf.h> | ||
| 17 | --- a/system/core/base/file.cpp | ||
| 18 | +++ b/system/core/base/file.cpp | ||
| 19 | @@ -26,6 +26,7 @@ | ||
| 20 | #include <sys/stat.h> | ||
| 21 | #include <sys/types.h> | ||
| 22 | #include <unistd.h> | ||
| 23 | +#include <cstring> | ||
| 24 | |||
| 25 | #include <memory> | ||
| 26 | #include <mutex> | ||
| 27 | --- a/system/core/libbacktrace/BacktraceMap.cpp | ||
| 28 | +++ b/system/core/libbacktrace/BacktraceMap.cpp | ||
| 29 | @@ -21,6 +21,7 @@ | ||
| 30 | #include <stdint.h> | ||
| 31 | #include <sys/types.h> | ||
| 32 | #include <unistd.h> | ||
| 33 | +#include <algorithm> | ||
| 34 | |||
| 35 | #include <log/log.h> | ||
| 36 | |||
| 37 | --- a/system/core/libbacktrace/UnwindStackMap.cpp | ||
| 38 | +++ b/system/core/libbacktrace/UnwindStackMap.cpp | ||
| 39 | @@ -20,6 +20,7 @@ | ||
| 40 | |||
| 41 | #include <string> | ||
| 42 | #include <vector> | ||
| 43 | +#include <algorithm> | ||
| 44 | |||
| 45 | #include <backtrace/BacktraceMap.h> | ||
| 46 | #include <unwindstack/Elf.h> | ||
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 @@ | |||
| 1 | Upstream-Status: Pending | ||
| 2 | |||
| 3 | Description: Bring Clang's _Nonnull keyword to GCC | ||
| 4 | Author: Kai-Chung Yan | ||
| 5 | Forwarded: not-needed | ||
| 6 | --- a/system/core/adb/sysdeps.h | ||
| 7 | +++ b/system/core/adb/sysdeps.h | ||
| 8 | @@ -40,11 +40,12 @@ | ||
| 9 | #include "sysdeps/network.h" | ||
| 10 | #include "sysdeps/stat.h" | ||
| 11 | |||
| 12 | +#define _Nonnull | ||
| 13 | +#define _Nullable | ||
| 14 | + | ||
| 15 | #ifdef _WIN32 | ||
| 16 | |||
| 17 | // Clang-only nullability specifiers | ||
| 18 | -#define _Nonnull | ||
| 19 | -#define _Nullable | ||
| 20 | |||
| 21 | #include <ctype.h> | ||
| 22 | #include <direct.h> | ||
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 @@ | |||
| 1 | Upstream-Status: Pending | ||
| 2 | |||
| 3 | Description: Fix the weird error by GCC7 that fails to match the correct parent method. | ||
| 4 | Author: Kai-Chung Yan | ||
| 5 | Forwarded: not-needed | ||
| 6 | --- a/system/core/libutils/include/utils/Vector.h | ||
| 7 | +++ b/system/core/libutils/include/utils/Vector.h | ||
| 8 | @@ -256,7 +256,7 @@ | ||
| 9 | |||
| 10 | template<class TYPE> inline | ||
| 11 | const Vector<TYPE>& Vector<TYPE>::operator = (const Vector<TYPE>& rhs) const { | ||
| 12 | - VectorImpl::operator = (static_cast<const VectorImpl&>(rhs)); | ||
| 13 | + VectorImpl::operator = (rhs); | ||
| 14 | return *this; | ||
| 15 | } | ||
| 16 | |||
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 @@ | |||
| 1 | Upstream-Status: Pending | ||
| 2 | |||
| 3 | Forwarded: not-needed | ||
| 4 | --- a/system/core/fs_mgr/liblp/reader.cpp | ||
| 5 | +++ b/system/core/fs_mgr/liblp/reader.cpp | ||
| 6 | @@ -22,6 +22,7 @@ | ||
| 7 | #include <unistd.h> | ||
| 8 | |||
| 9 | #include <functional> | ||
| 10 | +#include <cstring> | ||
| 11 | |||
| 12 | #include <android-base/file.h> | ||
| 13 | #include <android-base/unique_fd.h> | ||
| 14 | --- a/system/core/fs_mgr/liblp/writer.cpp | ||
| 15 | +++ b/system/core/fs_mgr/liblp/writer.cpp | ||
| 16 | @@ -21,6 +21,7 @@ | ||
| 17 | #include <unistd.h> | ||
| 18 | |||
| 19 | #include <string> | ||
| 20 | +#include <cstring> | ||
| 21 | |||
| 22 | #include <android-base/file.h> | ||
| 23 | #include <android-base/unique_fd.h> | ||
| 24 | --- a/system/core/liblog/logger_write.cpp | ||
| 25 | +++ b/system/core/liblog/logger_write.cpp | ||
| 26 | @@ -27,6 +27,7 @@ | ||
| 27 | #include <android/set_abort_message.h> | ||
| 28 | #endif | ||
| 29 | |||
| 30 | +#include <mutex> | ||
| 31 | #include <shared_mutex> | ||
| 32 | |||
| 33 | #include <android-base/errno_restorer.h> | ||
| 34 | --- a/system/core/libziparchive/zip_archive_stream_entry.cc | ||
| 35 | +++ b/system/core/libziparchive/zip_archive_stream_entry.cc | ||
| 36 | @@ -23,6 +23,7 @@ | ||
| 37 | #include <sys/types.h> | ||
| 38 | #include <unistd.h> | ||
| 39 | |||
| 40 | +#include <limits> | ||
| 41 | #include <memory> | ||
| 42 | #include <vector> | ||
| 43 | |||
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 @@ | |||
| 1 | Upstream-Status: Pending | ||
| 2 | |||
| 3 | Description: Off-by-one error in the dwarf_to_unw_regnum function in include/dwarf_i.h in | ||
| 4 | libunwind 1.1 allows local users to have unspecified impact via invalid dwarf opcodes. | ||
| 5 | --- a/external/libunwind/include/dwarf_i.h | ||
| 6 | +++ b/external/libunwind/include/dwarf_i.h | ||
| 7 | @@ -20,7 +20,7 @@ | ||
| 8 | extern const uint8_t dwarf_to_unw_regnum_map[DWARF_REGNUM_MAP_LENGTH]; | ||
| 9 | /* REG is evaluated multiple times; it better be side-effects free! */ | ||
| 10 | # define dwarf_to_unw_regnum(reg) \ | ||
| 11 | - (((reg) <= DWARF_REGNUM_MAP_LENGTH) ? dwarf_to_unw_regnum_map[reg] : 0) | ||
| 12 | + (((reg) < DWARF_REGNUM_MAP_LENGTH) ? dwarf_to_unw_regnum_map[reg] : 0) | ||
| 13 | #endif | ||
| 14 | |||
| 15 | #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 @@ | |||
| 1 | Upstream-Status: Pending | ||
| 2 | |||
| 3 | Description: Replace the legacy __sync built-in functions with __atomic ones | ||
| 4 | libunwind uses the built-in __sync_* functions which are deprecated by GCC and | ||
| 5 | should be replaced by __atomic_* ones. See the official manuals [1]. | ||
| 6 | . | ||
| 7 | The legacy __sync functions do not require to specify the memory order but | ||
| 8 | __atomic ones do, so we choose the strongest one: __ATOMIC_SEQ_CST. | ||
| 9 | . | ||
| 10 | We do this because __sync_fetch_and_add() is not supported on armel. | ||
| 11 | . | ||
| 12 | [1]: https://gcc.gnu.org/onlinedocs/gcc/_005f_005fsync-Builtins.html | ||
| 13 | Author: Kai-Chung Yan () | ||
| 14 | Last-Update: 2016-10-04 | ||
| 15 | Forwarded: not-needed | ||
| 16 | --- a/external/libunwind/include/libunwind_i.h | ||
| 17 | +++ b/external/libunwind/include/libunwind_i.h | ||
| 18 | @@ -155,8 +155,8 @@ cmpxchg_ptr (void *addr, void *old, void | ||
| 19 | u.vp = addr; | ||
| 20 | return __sync_bool_compare_and_swap(u.vlp, (long) old, (long) new); | ||
| 21 | } | ||
| 22 | -# define fetch_and_add1(_ptr) __sync_fetch_and_add(_ptr, 1) | ||
| 23 | -# define fetch_and_add(_ptr, value) __sync_fetch_and_add(_ptr, value) | ||
| 24 | +# define fetch_and_add1(_ptr) __atomic_fetch_add(_ptr, 1, __ATOMIC_SEQ_CST) | ||
| 25 | +# define fetch_and_add(_ptr, value) __atomic_fetch_add(_ptr, value, __ATOMIC_SEQ_CST) | ||
| 26 | # define HAVE_CMPXCHG | ||
| 27 | # define HAVE_FETCH_AND_ADD | ||
| 28 | #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 @@ | |||
| 1 | From d91f5324f809c3a5b0343927716e4b99bc31db53 Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Viswanath Kraleti <viswanath.kraleti@oss.qualcomm.com> | ||
| 3 | Date: Fri, 13 Mar 2026 18:57:36 +0530 | ||
| 4 | Subject: [PATCH] libunwind: fix strchr() conformance to ISO C23 | ||
| 5 | |||
| 6 | Fix uses of strchr() to conform to ISO C23, supported since glibc-2.43 | ||
| 7 | |||
| 8 | Signed-off-by: Viswanath Kraleti <viswanath.kraleti@oss.qualcomm.com> | ||
| 9 | Upstream-Status: Pending | ||
| 10 | --- | ||
| 11 | external/libunwind/src/dwarf/Gfind_proc_info-lsb.c | 3 ++- | ||
| 12 | 1 file changed, 2 insertions(+), 1 deletion(-) | ||
| 13 | |||
| 14 | diff --git a/external/libunwind/src/dwarf/Gfind_proc_info-lsb.c b/external/libunwind/src/dwarf/Gfind_proc_info-lsb.c | ||
| 15 | index 77ed3d09..37eadf52 100644 | ||
| 16 | --- a/external/libunwind/src/dwarf/Gfind_proc_info-lsb.c | ||
| 17 | +++ b/external/libunwind/src/dwarf/Gfind_proc_info-lsb.c | ||
| 18 | @@ -248,7 +248,8 @@ load_debug_frame (const char *file, char **buf, size_t *bufsize, | ||
| 19 | |||
| 20 | if (*buf == NULL && linkbuf != NULL && memchr (linkbuf, 0, linksize) != NULL) | ||
| 21 | { | ||
| 22 | - char *newname, *basedir, *p; | ||
| 23 | + char *newname, *basedir; | ||
| 24 | + const char *p; | ||
| 25 | static const char *debugdir = "/usr/lib/debug"; | ||
| 26 | int ret; | ||
| 27 | |||
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 @@ | |||
| 1 | From e64495a109eefaf87235729f4dd79fc9121c16a6 Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Sasi Kumar Maddineni <quic_sasikuma@quicinc.com> | ||
| 3 | Date: Mon, 27 Oct 2025 19:39:05 +0530 | ||
| 4 | Subject: [PATCH] libunwind: guard unreachable() macro to avoid redefinition | ||
| 5 | with stddef.h | ||
| 6 | |||
| 7 | The build fails due to a macro redefinition conflict for `unreachable()`. | ||
| 8 | GCC 15.2.0 defines `unreachable()` in `stddef.h`, and `libunwind_i.h` also | ||
| 9 | defines it based on the presence of `HAVE__BUILTIN_UNREACHABLE`. This causes | ||
| 10 | a redefinition error when building with `-Werror`. | ||
| 11 | |||
| 12 | Added a guard around the `unreachable()` macro definition in `libunwind_i.h` | ||
| 13 | to ensure it is only defined if not already present. | ||
| 14 | |||
| 15 | Upstream-Status: Pending | ||
| 16 | |||
| 17 | Signed-off-by: Sasi Kumar Maddineni <quic_sasikuma@quicinc.com> | ||
| 18 | --- | ||
| 19 | external/libunwind/include/libunwind_i.h | 2 ++ | ||
| 20 | 1 file changed, 2 insertions(+) | ||
| 21 | |||
| 22 | diff --git a/external/libunwind/include/libunwind_i.h b/external/libunwind/include/libunwind_i.h | ||
| 23 | index c06912a6..59a462df 100644 | ||
| 24 | --- a/external/libunwind/include/libunwind_i.h | ||
| 25 | +++ b/external/libunwind/include/libunwind_i.h | ||
| 26 | @@ -88,11 +88,13 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ | ||
| 27 | # endif | ||
| 28 | #endif | ||
| 29 | |||
| 30 | +#if !defined(unreachable) | ||
| 31 | #if defined(HAVE__BUILTIN_UNREACHABLE) | ||
| 32 | # define unreachable() __builtin_unreachable() | ||
| 33 | #else | ||
| 34 | # define unreachable() do { } while (1) | ||
| 35 | #endif | ||
| 36 | +#endif | ||
| 37 | |||
| 38 | #ifdef DEBUG | ||
| 39 | # define UNW_DEBUG 1 | ||
| 40 | -- | ||
| 41 | 2.34.1 | ||
| 42 | |||
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 @@ | |||
| 1 | Upstream-Status: Pending | ||
| 2 | |||
| 3 | Author: Kai-Chung Yan <seamlikok@gmail.com> | ||
| 4 | Last-Update: 2016-08-24 | ||
| 5 | Description: Manual definition of struct user_pt_regs | ||
| 6 | On ARM64, libunwind uses struct user_pt_regs which is not defined in | ||
| 7 | anywhere, which causes FTBFS. | ||
| 8 | Forwarded: not-needed | ||
| 9 | --- a/external/libunwind/src/ptrace/_UPT_access_reg.c | ||
| 10 | +++ b/external/libunwind/src/ptrace/_UPT_access_reg.c | ||
| 11 | @@ -26,6 +26,15 @@ WITH THE SOFTWARE OR THE USE OR OTHER DE | ||
| 12 | |||
| 13 | #include "_UPT_internal.h" | ||
| 14 | |||
| 15 | +#if defined(__aarch64__) | ||
| 16 | + struct user_pt_regs { | ||
| 17 | + __u64 regs[31]; | ||
| 18 | + __u64 sp; | ||
| 19 | + __u64 pc; | ||
| 20 | + __u64 pstate; | ||
| 21 | + }; | ||
| 22 | +#endif | ||
| 23 | + | ||
| 24 | #if UNW_TARGET_IA64 | ||
| 25 | # include <elf.h> | ||
| 26 | # 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 @@ | |||
| 1 | Upstream-Status: Pending | ||
| 2 | |||
| 3 | Description: remove clang-ism | ||
| 4 | Forwarded: not-needed | ||
| 5 | |||
| 6 | --- a/system/core/base/include/android-base/logging.h | ||
| 7 | +++ b/system/core/base/include/android-base/logging.h | ||
| 8 | @@ -451,10 +451,7 @@ | ||
| 9 | // -Wno-user-defined-warnings to CPPFLAGS. | ||
| 10 | #pragma clang diagnostic push | ||
| 11 | #pragma clang diagnostic ignored "-Wgcc-compat" | ||
| 12 | -#define OSTREAM_STRING_POINTER_USAGE_WARNING \ | ||
| 13 | - __attribute__((diagnose_if(true, "Unexpected logging of string pointer", "warning"))) | ||
| 14 | -inline OSTREAM_STRING_POINTER_USAGE_WARNING | ||
| 15 | -std::ostream& operator<<(std::ostream& stream, const std::string* string_pointer) { | ||
| 16 | +inline std::ostream& operator<<(std::ostream& stream, const std::string* string_pointer) { | ||
| 17 | return stream << static_cast<const void*>(string_pointer); | ||
| 18 | } | ||
| 19 | #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 @@ | |||
| 1 | Upstream-Status: Pending | ||
| 2 | |||
| 3 | Description: non-x86 arches do not have PAGE_SIZE | ||
| 4 | Forwarded: not-needed | ||
| 5 | --- a/system/core/base/cmsg.cpp | ||
| 6 | +++ b/system/core/base/cmsg.cpp | ||
| 7 | @@ -33,7 +33,8 @@ | ||
| 8 | const std::vector<int>& fds) { | ||
| 9 | size_t cmsg_space = CMSG_SPACE(sizeof(int) * fds.size()); | ||
| 10 | size_t cmsg_len = CMSG_LEN(sizeof(int) * fds.size()); | ||
| 11 | - if (cmsg_space >= PAGE_SIZE) { | ||
| 12 | + size_t pagesize = static_cast<size_t>(sysconf(_SC_PAGE_SIZE)); | ||
| 13 | + if (cmsg_space >= pagesize) { | ||
| 14 | errno = ENOMEM; | ||
| 15 | return -1; | ||
| 16 | } | ||
| 17 | @@ -75,7 +76,8 @@ | ||
| 18 | fds->clear(); | ||
| 19 | |||
| 20 | size_t cmsg_space = CMSG_SPACE(sizeof(int) * max_fds); | ||
| 21 | - if (cmsg_space >= PAGE_SIZE) { | ||
| 22 | + size_t pagesize = static_cast<size_t>(sysconf(_SC_PAGE_SIZE)); | ||
| 23 | + if (cmsg_space >= pagesize) { | ||
| 24 | errno = ENOMEM; | ||
| 25 | return -1; | ||
| 26 | } | ||
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 @@ | |||
| 1 | Upstream-Status: Pending | ||
| 2 | |||
| 3 | Description: get libcutils building | ||
| 4 | Forwarded: not-needed | ||
| 5 | --- a/system/core/libcutils/include/cutils/threads.h | ||
| 6 | +++ b/system/core/libcutils/include/cutils/threads.h | ||
| 7 | @@ -33,7 +33,7 @@ | ||
| 8 | // Deprecated: use android::base::GetThreadId instead, which doesn't truncate on Mac/Windows. | ||
| 9 | // | ||
| 10 | |||
| 11 | -extern pid_t gettid(); | ||
| 12 | +extern pid_t gettid(void) __THROW; | ||
| 13 | |||
| 14 | // | ||
| 15 | // Deprecated: use `_Thread_local` in C or `thread_local` in C++. | ||
| 16 | --- a/system/core/libcutils/threads.cpp | ||
| 17 | +++ b/system/core/libcutils/threads.cpp | ||
| 18 | @@ -33,7 +33,7 @@ | ||
| 19 | |||
| 20 | // No definition needed for Android because we'll just pick up bionic's copy. | ||
| 21 | #ifndef __ANDROID__ | ||
| 22 | -pid_t gettid() { | ||
| 23 | +pid_t gettid(void) __THROW { | ||
| 24 | #if defined(__APPLE__) | ||
| 25 | uint64_t tid; | ||
| 26 | 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 @@ | |||
| 1 | Upstream-Status: Pending | ||
| 2 | |||
| 3 | Description: Add missing 'std::' scope identifiers. | ||
| 4 | Forwarded: not-needed | ||
| 5 | --- a/system/core/libunwindstack/include/unwindstack/DwarfMemory.h | ||
| 6 | +++ b/system/core/libunwindstack/include/unwindstack/DwarfMemory.h | ||
| 7 | @@ -29,7 +29,7 @@ | ||
| 8 | DwarfMemory(Memory* memory) : memory_(memory) {} | ||
| 9 | virtual ~DwarfMemory() = default; | ||
| 10 | |||
| 11 | - bool ReadBytes(void* dst, size_t num_bytes); | ||
| 12 | + bool ReadBytes(void* dst, std::size_t num_bytes); | ||
| 13 | |||
| 14 | template <typename SignedType> | ||
| 15 | bool ReadSigned(uint64_t* value); | ||
| 16 | @@ -39,7 +39,7 @@ | ||
| 17 | bool ReadSLEB128(int64_t* value); | ||
| 18 | |||
| 19 | template <typename AddressType> | ||
| 20 | - size_t GetEncodedSize(uint8_t encoding); | ||
| 21 | + std::size_t GetEncodedSize(uint8_t encoding); | ||
| 22 | |||
| 23 | bool AdjustEncodedValue(uint8_t encoding, uint64_t* value); | ||
| 24 | |||
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 @@ | |||
| 1 | Upstream-Status: Pending | ||
| 2 | |||
| 3 | Description: just hard code rather than deal with circular deps | ||
| 4 | Forwarded: not-needed | ||
| 5 | --- a/system/core/adb/adb.cpp | ||
| 6 | +++ b/system/core/adb/adb.cpp | ||
| 7 | @@ -44,8 +44,6 @@ | ||
| 8 | #include <android-base/parsenetaddress.h> | ||
| 9 | #include <android-base/stringprintf.h> | ||
| 10 | #include <android-base/strings.h> | ||
| 11 | -#include <build/version.h> | ||
| 12 | -#include <platform_tools_version.h> | ||
| 13 | |||
| 14 | #include "adb_auth.h" | ||
| 15 | #include "adb_io.h" | ||
| 16 | @@ -69,7 +67,7 @@ | ||
| 17 | "Version %s-%s\n" | ||
| 18 | "Installed as %s\n", | ||
| 19 | ADB_VERSION_MAJOR, ADB_VERSION_MINOR, ADB_SERVER_VERSION, | ||
| 20 | - PLATFORM_TOOLS_VERSION, android::build::GetBuildNumber().c_str(), | ||
| 21 | + PLATFORM_TOOLS_VERSION, "debian", | ||
| 22 | android::base::GetExecutablePath().c_str()); | ||
| 23 | } | ||
| 24 | |||
| 25 | --- a/system/core/fastboot/fastboot.cpp | ||
| 26 | +++ b/system/core/fastboot/fastboot.cpp | ||
| 27 | @@ -59,10 +59,8 @@ | ||
| 28 | #include <android-base/stringprintf.h> | ||
| 29 | #include <android-base/strings.h> | ||
| 30 | #include <android-base/unique_fd.h> | ||
| 31 | -#include <build/version.h> | ||
| 32 | #include <libavb/libavb.h> | ||
| 33 | #include <liblp/liblp.h> | ||
| 34 | -#include <platform_tools_version.h> | ||
| 35 | #include <sparse/sparse.h> | ||
| 36 | #include <ziparchive/zip_archive.h> | ||
| 37 | |||
| 38 | @@ -1680,7 +1678,7 @@ | ||
| 39 | setvbuf(stdout, nullptr, _IONBF, 0); | ||
| 40 | setvbuf(stderr, nullptr, _IONBF, 0); | ||
| 41 | } else if (name == "version") { | ||
| 42 | - fprintf(stdout, "fastboot version %s-%s\n", PLATFORM_TOOLS_VERSION, android::build::GetBuildNumber().c_str()); | ||
| 43 | + fprintf(stdout, "fastboot version %s-%s\n", PLATFORM_TOOLS_VERSION, "debian"); | ||
| 44 | fprintf(stdout, "Installed as %s\n", android::base::GetExecutablePath().c_str()); | ||
| 45 | return 0; | ||
| 46 | #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 @@ | |||
| 1 | Upstream-Status: Pending | ||
| 2 | |||
| 3 | Description: libusb.h comes from different location | ||
| 4 | Author: Umang Parmar <umangjparmar@gmail.com> | ||
| 5 | Forwarded: not-needed | ||
| 6 | Last-Update: 2018-05-26 | ||
| 7 | |||
| 8 | --- a/system/core/adb/client/usb_libusb.cpp | ||
| 9 | +++ b/system/core/adb/client/usb_libusb.cpp | ||
| 10 | @@ -30,7 +30,7 @@ | ||
| 11 | #include <thread> | ||
| 12 | #include <unordered_map> | ||
| 13 | |||
| 14 | -#include <libusb/libusb.h> | ||
| 15 | +#include <libusb-1.0/libusb.h> | ||
| 16 | |||
| 17 | #include <android-base/file.h> | ||
| 18 | #include <android-base/logging.h> | ||
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 @@ | |||
| 1 | Upstream-Status: Pending | ||
| 2 | |||
| 3 | Description: Update log file directory. | ||
| 4 | Author: Umang Parmar <umangjparmar@gmail.com> | ||
| 5 | Last Updated: 2018-05-17 | ||
| 6 | |||
| 7 | --- a/system/core/adb/adb_utils.cpp | ||
| 8 | +++ b/system/core/adb/adb_utils.cpp | ||
| 9 | @@ -339,6 +339,11 @@ | ||
| 10 | |||
| 11 | return temp_path_utf8 + log_name; | ||
| 12 | #else | ||
| 13 | + std::string log_dir = android::base::StringPrintf("/run/user/%u/adb.log", getuid()); | ||
| 14 | + struct stat st = {0}; | ||
| 15 | + if (stat(log_dir.c_str(), &st) == 0) { | ||
| 16 | + return log_dir; | ||
| 17 | + } | ||
| 18 | const char* tmp_dir = getenv("TMPDIR"); | ||
| 19 | if (tmp_dir == nullptr) tmp_dir = "/tmp"; | ||
| 20 | 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 @@ | |||
| 1 | Description: Port simg_dump to Python 3. | ||
| 2 | Author: Antonio Russo <antonio.e.russo@gmail.com> | ||
| 3 | Forwarded: not-needed | ||
| 4 | Last-Update: 2019-01-05 | ||
| 5 | Origin: https://bugs.debian.org/945646 | ||
| 6 | |||
| 7 | --- | ||
| 8 | Upstream-Status: Pending | ||
| 9 | |||
| 10 | Index: android-platform-tools/system/core/libsparse/simg_dump.py | ||
| 11 | =================================================================== | ||
| 12 | --- android-platform-tools.orig/system/core/libsparse/simg_dump.py | ||
| 13 | +++ android-platform-tools/system/core/libsparse/simg_dump.py | ||
| 14 | @@ -1,4 +1,4 @@ | ||
| 15 | -#! /usr/bin/env python | ||
| 16 | +#! /usr/bin/env python3 | ||
| 17 | |||
| 18 | # Copyright (C) 2012 The Android Open Source Project | ||
| 19 | # | ||
| 20 | @@ -14,7 +14,7 @@ | ||
| 21 | # See the License for the specific language governing permissions and | ||
| 22 | # limitations under the License. | ||
| 23 | |||
| 24 | -from __future__ import print_function | ||
| 25 | + | ||
| 26 | import csv | ||
| 27 | import getopt | ||
| 28 | import hashlib | ||
| 29 | @@ -47,7 +47,7 @@ def main(): | ||
| 30 | opts, args = getopt.getopt(sys.argv[1:], | ||
| 31 | "vsc:", | ||
| 32 | ["verbose", "showhash", "csvfile"]) | ||
| 33 | - except getopt.GetoptError, e: | ||
| 34 | + except getopt.GetoptError as e: | ||
| 35 | print(e) | ||
| 36 | usage(me) | ||
| 37 | for o, a in opts: | ||
| 38 | @@ -66,7 +66,7 @@ def main(): | ||
| 39 | usage(me) | ||
| 40 | |||
| 41 | if csvfilename: | ||
| 42 | - csvfile = open(csvfilename, "wb") | ||
| 43 | + csvfile = open(csvfilename, "w", newline='') | ||
| 44 | csvwriter = csv.writer(csvfile) | ||
| 45 | |||
| 46 | output = verbose or csvfilename or showhash | ||
| 47 | @@ -121,7 +121,7 @@ def main(): | ||
| 48 | "output offset", "output blocks", "type", "hash"]) | ||
| 49 | |||
| 50 | offset = 0 | ||
| 51 | - for i in xrange(1, total_chunks + 1): | ||
| 52 | + for i in range(1, total_chunks + 1): | ||
| 53 | header_bin = FH.read(12) | ||
| 54 | header = struct.unpack("<2H2I", header_bin) | ||
| 55 | chunk_type = header[0] | ||
| 56 | @@ -160,7 +160,7 @@ def main(): | ||
| 57 | if showhash: | ||
| 58 | h = hashlib.sha1() | ||
| 59 | data = fill_bin * (blk_sz / 4); | ||
| 60 | - for block in xrange(chunk_sz): | ||
| 61 | + for block in range(chunk_sz): | ||
| 62 | h.update(data) | ||
| 63 | curhash = h.hexdigest() | ||
| 64 | 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 @@ | |||
| 1 | Upstream-Status: Pending | ||
| 2 | |||
| 3 | Description: Fix incompatibility between <stdatomic.h> and <atomic> | ||
| 4 | This 2 headers combined will cause errors for both GCC and Clang. This patch | ||
| 5 | makes sure only one of them is present at any time. | ||
| 6 | Bug: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60932 | ||
| 7 | Bug: https://reviews.llvm.org/D45470 | ||
| 8 | --- a/system/core/libcutils/include/cutils/trace.h | ||
| 9 | +++ b/system/core/libcutils/include/cutils/trace.h | ||
| 10 | @@ -18,7 +18,14 @@ | ||
| 11 | #define _LIBS_CUTILS_TRACE_H | ||
| 12 | |||
| 13 | #include <inttypes.h> | ||
| 14 | +#ifdef __cplusplus | ||
| 15 | +#include <atomic> | ||
| 16 | +using std::atomic_bool; | ||
| 17 | +using std::atomic_load_explicit; | ||
| 18 | +using std::memory_order_acquire; | ||
| 19 | +#else | ||
| 20 | #include <stdatomic.h> | ||
| 21 | +#endif | ||
| 22 | #include <stdbool.h> | ||
| 23 | #include <stdint.h> | ||
| 24 | #include <stdio.h> | ||
| 25 | --- a/system/core/libcutils/include/cutils/atomic.h | ||
| 26 | +++ b/system/core/libcutils/include/cutils/atomic.h | ||
| 27 | @@ -19,7 +19,23 @@ | ||
| 28 | |||
| 29 | #include <stdint.h> | ||
| 30 | #include <sys/types.h> | ||
| 31 | +#ifdef __cplusplus | ||
| 32 | +#include <atomic> | ||
| 33 | +using std::atomic_compare_exchange_strong_explicit; | ||
| 34 | +using std::atomic_fetch_add_explicit; | ||
| 35 | +using std::atomic_fetch_or_explicit; | ||
| 36 | +using std::atomic_fetch_sub_explicit; | ||
| 37 | +using std::atomic_int_least32_t; | ||
| 38 | +using std::atomic_load_explicit; | ||
| 39 | +using std::atomic_store_explicit; | ||
| 40 | +using std::atomic_thread_fence; | ||
| 41 | +using std::memory_order::memory_order_acquire; | ||
| 42 | +using std::memory_order::memory_order_relaxed; | ||
| 43 | +using std::memory_order::memory_order_release; | ||
| 44 | +using std::memory_order::memory_order_seq_cst; | ||
| 45 | +#else | ||
| 46 | #include <stdatomic.h> | ||
| 47 | +#endif | ||
| 48 | |||
| 49 | #ifndef ANDROID_ATOMIC_INLINE | ||
| 50 | #define ANDROID_ATOMIC_INLINE static inline | ||
| 51 | --- a/system/core/liblog/logger.h | ||
| 52 | +++ b/system/core/liblog/logger.h | ||
| 53 | @@ -16,7 +16,13 @@ | ||
| 54 | |||
| 55 | #pragma once | ||
| 56 | |||
| 57 | +#ifdef __cplusplus | ||
| 58 | +#include <atomic> | ||
| 59 | +using std::atomic_int; | ||
| 60 | +using std::atomic_uintptr_t; | ||
| 61 | +#else | ||
| 62 | #include <stdatomic.h> | ||
| 63 | +#endif | ||
| 64 | #include <sys/cdefs.h> | ||
| 65 | |||
| 66 | #include <log/log.h> | ||
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 @@ | |||
| 1 | Upstream-Status: Pending | ||
| 2 | |||
| 3 | Description: Defer packaging fastdeploy with adb for 29.x.x tags. | ||
| 4 | Forwarded: not-needed | ||
| 5 | --- a/system/core/adb/client/commandline.cpp | ||
| 6 | +++ b/system/core/adb/client/commandline.cpp | ||
| 7 | @@ -59,7 +59,6 @@ | ||
| 8 | #include "bugreport.h" | ||
| 9 | #include "client/file_sync_client.h" | ||
| 10 | #include "commandline.h" | ||
| 11 | -#include "fastdeploy.h" | ||
| 12 | #include "services.h" | ||
| 13 | #include "shell_protocol.h" | ||
| 14 | #include "sysdeps/chrono.h" | ||
| 15 | --- a/system/core/adb/client/adb_install.cpp | ||
| 16 | +++ b/system/core/adb/client/adb_install.cpp | ||
| 17 | @@ -35,7 +35,6 @@ | ||
| 18 | #include "adb_utils.h" | ||
| 19 | #include "client/file_sync_client.h" | ||
| 20 | #include "commandline.h" | ||
| 21 | -#include "fastdeploy.h" | ||
| 22 | |||
| 23 | static constexpr int kFastDeployMinApi = 24; | ||
| 24 | |||
| 25 | @@ -167,14 +166,6 @@ | ||
| 26 | } | ||
| 27 | |||
| 28 | if (use_fastdeploy) { | ||
| 29 | - auto metadata = extract_metadata(file); | ||
| 30 | - if (metadata.has_value()) { | ||
| 31 | - // pass all but 1st (command) and last (apk path) parameters through to pm for | ||
| 32 | - // session creation | ||
| 33 | - std::vector<const char*> pm_args{argv + 1, argv + argc - 1}; | ||
| 34 | - auto patchFd = install_patch(pm_args.size(), pm_args.data()); | ||
| 35 | - return stream_patch(file, std::move(metadata.value()), std::move(patchFd)); | ||
| 36 | - } | ||
| 37 | } | ||
| 38 | |||
| 39 | struct stat sb; | ||
| 40 | @@ -267,16 +258,6 @@ | ||
| 41 | argv[last_apk] = apk_dest.c_str(); /* destination name, not source location */ | ||
| 42 | |||
| 43 | if (use_fastdeploy) { | ||
| 44 | - auto metadata = extract_metadata(apk_file[0]); | ||
| 45 | - if (metadata.has_value()) { | ||
| 46 | - auto patchFd = apply_patch_on_device(apk_dest.c_str()); | ||
| 47 | - int status = stream_patch(apk_file[0], std::move(metadata.value()), std::move(patchFd)); | ||
| 48 | - | ||
| 49 | - result = pm_command(argc, argv); | ||
| 50 | - delete_device_file(apk_dest); | ||
| 51 | - | ||
| 52 | - return status; | ||
| 53 | - } | ||
| 54 | } | ||
| 55 | |||
| 56 | if (do_sync_push(apk_file, apk_dest.c_str(), false)) { | ||
| 57 | @@ -292,7 +273,6 @@ | ||
| 58 | InstallMode installMode = INSTALL_DEFAULT; | ||
| 59 | bool use_fastdeploy = false; | ||
| 60 | bool is_reinstall = false; | ||
| 61 | - FastDeploy_AgentUpdateStrategy agent_update_strategy = FastDeploy_AgentUpdateDifferentVersion; | ||
| 62 | |||
| 63 | for (int i = 1; i < argc; i++) { | ||
| 64 | if (!strcmp(argv[i], "--streaming")) { | ||
| 65 | @@ -313,13 +293,10 @@ | ||
| 66 | use_fastdeploy = false; | ||
| 67 | } else if (!strcmp(argv[i], "--force-agent")) { | ||
| 68 | processedArgIndicies.push_back(i); | ||
| 69 | - agent_update_strategy = FastDeploy_AgentUpdateAlways; | ||
| 70 | } else if (!strcmp(argv[i], "--date-check-agent")) { | ||
| 71 | processedArgIndicies.push_back(i); | ||
| 72 | - agent_update_strategy = FastDeploy_AgentUpdateNewerTimeStamp; | ||
| 73 | } else if (!strcmp(argv[i], "--version-check-agent")) { | ||
| 74 | processedArgIndicies.push_back(i); | ||
| 75 | - agent_update_strategy = FastDeploy_AgentUpdateDifferentVersion; | ||
| 76 | } | ||
| 77 | } | ||
| 78 | |||
| 79 | @@ -331,13 +308,11 @@ | ||
| 80 | error_exit("Attempting to use streaming install on unsupported device"); | ||
| 81 | } | ||
| 82 | |||
| 83 | - if (use_fastdeploy && get_device_api_level() < kFastDeployMinApi) { | ||
| 84 | - printf("Fast Deploy is only compatible with devices of API version %d or higher, " | ||
| 85 | - "ignoring.\n", | ||
| 86 | - kFastDeployMinApi); | ||
| 87 | + if (use_fastdeploy) { | ||
| 88 | + printf("Fast Deploy is unavailable in this build of adb, " | ||
| 89 | + "ignoring.\n"); | ||
| 90 | use_fastdeploy = false; | ||
| 91 | } | ||
| 92 | - fastdeploy_set_agent_update_strategy(agent_update_strategy); | ||
| 93 | |||
| 94 | std::vector<const char*> passthrough_argv; | ||
| 95 | 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 @@ | |||
| 1 | From: Guo Ren <guoren@linux.alibaba.com> | ||
| 2 | Date: Wed, 29 Jun 2022 16:46:46 +0800 | ||
| 3 | Subject: Add riscv64 support | ||
| 4 | |||
| 5 | This patch contains the dwarf unwind support for 64bit risc-v. | ||
| 6 | |||
| 7 | * DwarfCfa.cpp (cfa_def_cfa_register): setup register if CFA_REG is | ||
| 8 | not setup for riscv64 | ||
| 9 | * Elf.cpp (GetRelPc): convert offset to virtual address for riscv64. | ||
| 10 | * ElfInterface.cpp (GetVirtAddrFromOffset): New for riscv64. | ||
| 11 | * RegsRiscv64.cpp (StepIfSignalHandler): Fix signal frame check. | ||
| 12 | libunwindstack/include/unwindstack/ | ||
| 13 | * ElfInterface.h (GetVirtAddrFromOffset): New for riscv64. | ||
| 14 | libunwindstack/tests/ | ||
| 15 | * DwarfCfaTest.cpp (cfa_def_cfa_register): ok for riscv64. | ||
| 16 | * RegsStepIfSignalHandlerTest.cpp (riscv64_step_if_signal_handler): Fix | ||
| 17 | testcase for riscv64 | ||
| 18 | |||
| 19 | Test: Builds. | ||
| 20 | Test: All unit tests pass. | ||
| 21 | |||
| 22 | Signed-off-by: Guo Ren <guoren@linux.alibaba.com> | ||
| 23 | Signed-off-by: Lifang Xia <lifang_xia@linux.alibaba.com> | ||
| 24 | Signed-off-by: Mao Han <han_mao@linux.alibaba.com> | ||
| 25 | Change-Id: Ib21ddf23cc83f332af202df7bffcaceec16063e0 | ||
| 26 | --- | ||
| 27 | Upstream-Status: Pending | ||
| 28 | |||
| 29 | system/core/libunwindstack/Android.bp | 1 + | ||
| 30 | system/core/libunwindstack/Elf.cpp | 2 + | ||
| 31 | system/core/libunwindstack/Regs.cpp | 10 ++ | ||
| 32 | system/core/libunwindstack/RegsRiscv64.cpp | 156 +++++++++++++++++++++ | ||
| 33 | .../core/libunwindstack/include/unwindstack/Elf.h | 5 + | ||
| 34 | .../include/unwindstack/MachineRiscv64.h | 59 ++++++++ | ||
| 35 | .../include/unwindstack/RegsGetLocal.h | 43 ++++++ | ||
| 36 | .../include/unwindstack/RegsRiscv64.h | 59 ++++++++ | ||
| 37 | .../include/unwindstack/UcontextRiscv64.h | 80 +++++++++++ | ||
| 38 | .../include/unwindstack/UserRiscv64.h | 37 +++++ | ||
| 39 | system/core/libunwindstack/tools/unwind.cpp | 3 + | ||
| 40 | .../core/libunwindstack/tools/unwind_symbols.cpp | 3 + | ||
| 41 | 12 files changed, 458 insertions(+) | ||
| 42 | create mode 100644 system/core/libunwindstack/RegsRiscv64.cpp | ||
| 43 | create mode 100644 system/core/libunwindstack/include/unwindstack/MachineRiscv64.h | ||
| 44 | create mode 100644 system/core/libunwindstack/include/unwindstack/RegsRiscv64.h | ||
| 45 | create mode 100644 system/core/libunwindstack/include/unwindstack/UcontextRiscv64.h | ||
| 46 | create mode 100644 system/core/libunwindstack/include/unwindstack/UserRiscv64.h | ||
| 47 | |||
| 48 | diff --git a/system/core/libunwindstack/Android.bp b/system/core/libunwindstack/Android.bp | ||
| 49 | index 3695f72..f1f9c68 100644 | ||
| 50 | --- a/system/core/libunwindstack/Android.bp | ||
| 51 | +++ b/system/core/libunwindstack/Android.bp | ||
| 52 | @@ -70,6 +70,7 @@ cc_library { | ||
| 53 | "RegsArm64.cpp", | ||
| 54 | "RegsX86.cpp", | ||
| 55 | "RegsX86_64.cpp", | ||
| 56 | + "RegsRiscv64.cpp", | ||
| 57 | "RegsMips.cpp", | ||
| 58 | "RegsMips64.cpp", | ||
| 59 | "Unwinder.cpp", | ||
| 60 | diff --git a/system/core/libunwindstack/Elf.cpp b/system/core/libunwindstack/Elf.cpp | ||
| 61 | index f01b092..3c2088b 100644 | ||
| 62 | --- a/system/core/libunwindstack/Elf.cpp | ||
| 63 | +++ b/system/core/libunwindstack/Elf.cpp | ||
| 64 | @@ -290,6 +290,8 @@ ElfInterface* Elf::CreateInterfaceFromMemory(Memory* memory) { | ||
| 65 | arch_ = ARCH_X86_64; | ||
| 66 | } else if (e_machine == EM_MIPS) { | ||
| 67 | arch_ = ARCH_MIPS64; | ||
| 68 | + } else if (e_machine == EM_RISCV) { | ||
| 69 | + arch_ = ARCH_RISCV64; | ||
| 70 | } else { | ||
| 71 | // Unsupported. | ||
| 72 | ALOGI("64 bit elf that is neither aarch64 nor x86_64 nor mips64: e_machine = %d\n", | ||
| 73 | diff --git a/system/core/libunwindstack/Regs.cpp b/system/core/libunwindstack/Regs.cpp | ||
| 74 | index c7dec52..447a554 100644 | ||
| 75 | --- a/system/core/libunwindstack/Regs.cpp | ||
| 76 | +++ b/system/core/libunwindstack/Regs.cpp | ||
| 77 | @@ -27,12 +27,14 @@ | ||
| 78 | #include <unwindstack/RegsArm64.h> | ||
| 79 | #include <unwindstack/RegsMips.h> | ||
| 80 | #include <unwindstack/RegsMips64.h> | ||
| 81 | +#include <unwindstack/RegsRiscv64.h> | ||
| 82 | #include <unwindstack/RegsX86.h> | ||
| 83 | #include <unwindstack/RegsX86_64.h> | ||
| 84 | #include <unwindstack/UserArm.h> | ||
| 85 | #include <unwindstack/UserArm64.h> | ||
| 86 | #include <unwindstack/UserMips.h> | ||
| 87 | #include <unwindstack/UserMips64.h> | ||
| 88 | +#include <unwindstack/UserRiscv64.h> | ||
| 89 | #include <unwindstack/UserX86.h> | ||
| 90 | #include <unwindstack/UserX86_64.h> | ||
| 91 | |||
| 92 | @@ -67,6 +69,8 @@ Regs* Regs::RemoteGet(pid_t pid) { | ||
| 93 | return RegsMips::Read(buffer.data()); | ||
| 94 | case sizeof(mips64_user_regs): | ||
| 95 | return RegsMips64::Read(buffer.data()); | ||
| 96 | + case sizeof(riscv64_user_regs): | ||
| 97 | + return RegsRiscv64::Read(buffer.data()); | ||
| 98 | } | ||
| 99 | return nullptr; | ||
| 100 | } | ||
| 101 | @@ -85,6 +89,8 @@ Regs* Regs::CreateFromUcontext(ArchEnum arch, void* ucontext) { | ||
| 102 | return RegsMips::CreateFromUcontext(ucontext); | ||
| 103 | case ARCH_MIPS64: | ||
| 104 | return RegsMips64::CreateFromUcontext(ucontext); | ||
| 105 | + case ARCH_RISCV64: | ||
| 106 | + return RegsRiscv64::CreateFromUcontext(ucontext); | ||
| 107 | case ARCH_UNKNOWN: | ||
| 108 | default: | ||
| 109 | return nullptr; | ||
| 110 | @@ -104,6 +110,8 @@ ArchEnum Regs::CurrentArch() { | ||
| 111 | return ARCH_MIPS; | ||
| 112 | #elif defined(__mips__) && defined(__LP64__) | ||
| 113 | return ARCH_MIPS64; | ||
| 114 | +#elif defined(__riscv) | ||
| 115 | + return ARCH_RISCV64; | ||
| 116 | #else | ||
| 117 | abort(); | ||
| 118 | #endif | ||
| 119 | @@ -123,6 +131,8 @@ Regs* Regs::CreateFromLocal() { | ||
| 120 | regs = new RegsMips(); | ||
| 121 | #elif defined(__mips__) && defined(__LP64__) | ||
| 122 | regs = new RegsMips64(); | ||
| 123 | +#elif defined(__riscv) | ||
| 124 | + regs = new RegsRiscv64(); | ||
| 125 | #else | ||
| 126 | abort(); | ||
| 127 | #endif | ||
| 128 | diff --git a/system/core/libunwindstack/RegsRiscv64.cpp b/system/core/libunwindstack/RegsRiscv64.cpp | ||
| 129 | new file mode 100644 | ||
| 130 | index 0000000..887762a | ||
| 131 | --- /dev/null | ||
| 132 | +++ b/system/core/libunwindstack/RegsRiscv64.cpp | ||
| 133 | @@ -0,0 +1,156 @@ | ||
| 134 | +/* | ||
| 135 | + * Copyright (C) 2022 The Android Open Source Project | ||
| 136 | + * | ||
| 137 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 138 | + * you may not use this file except in compliance with the License. | ||
| 139 | + * You may obtain a copy of the License at | ||
| 140 | + * | ||
| 141 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
| 142 | + * | ||
| 143 | + * Unless required by applicable law or agreed to in writing, software | ||
| 144 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
| 145 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 146 | + * See the License for the specific language governing permissions and | ||
| 147 | + * limitations under the License. | ||
| 148 | + */ | ||
| 149 | + | ||
| 150 | +#include <stdint.h> | ||
| 151 | +#include <string.h> | ||
| 152 | + | ||
| 153 | +#include <functional> | ||
| 154 | + | ||
| 155 | +#include <unwindstack/Elf.h> | ||
| 156 | +#include <unwindstack/MachineRiscv64.h> | ||
| 157 | +#include <unwindstack/MapInfo.h> | ||
| 158 | +#include <unwindstack/Memory.h> | ||
| 159 | +#include <unwindstack/RegsRiscv64.h> | ||
| 160 | +#include <unwindstack/UcontextRiscv64.h> | ||
| 161 | +#include <unwindstack/UserRiscv64.h> | ||
| 162 | + | ||
| 163 | +namespace unwindstack { | ||
| 164 | + | ||
| 165 | +RegsRiscv64::RegsRiscv64() | ||
| 166 | + : RegsImpl<uint64_t>(RISCV64_REG_MAX, Location(LOCATION_REGISTER, RISCV64_REG_RA)) {} | ||
| 167 | + | ||
| 168 | +ArchEnum RegsRiscv64::Arch() { | ||
| 169 | + return ARCH_RISCV64; | ||
| 170 | +} | ||
| 171 | + | ||
| 172 | +uint64_t RegsRiscv64::pc() { | ||
| 173 | + return regs_[RISCV64_REG_PC]; | ||
| 174 | +} | ||
| 175 | + | ||
| 176 | +uint64_t RegsRiscv64::sp() { | ||
| 177 | + return regs_[RISCV64_REG_SP]; | ||
| 178 | +} | ||
| 179 | + | ||
| 180 | +void RegsRiscv64::set_pc(uint64_t pc) { | ||
| 181 | + regs_[RISCV64_REG_PC] = pc; | ||
| 182 | +} | ||
| 183 | + | ||
| 184 | +void RegsRiscv64::set_sp(uint64_t sp) { | ||
| 185 | + regs_[RISCV64_REG_SP] = sp; | ||
| 186 | +} | ||
| 187 | + | ||
| 188 | +uint64_t RegsRiscv64::GetPcAdjustment(uint64_t rel_pc, Elf*) { | ||
| 189 | + if (rel_pc < 8) { | ||
| 190 | + return 0; | ||
| 191 | + } | ||
| 192 | + // For now, just assume no compact branches | ||
| 193 | + return 8; | ||
| 194 | +} | ||
| 195 | + | ||
| 196 | +bool RegsRiscv64::SetPcFromReturnAddress(Memory*) { | ||
| 197 | + uint64_t ra = regs_[RISCV64_REG_RA]; | ||
| 198 | + if (regs_[RISCV64_REG_PC] == ra) { | ||
| 199 | + return false; | ||
| 200 | + } | ||
| 201 | + | ||
| 202 | + regs_[RISCV64_REG_PC] = ra; | ||
| 203 | + return true; | ||
| 204 | +} | ||
| 205 | + | ||
| 206 | +void RegsRiscv64::IterateRegisters(std::function<void(const char*, uint64_t)> fn) { | ||
| 207 | + fn("pc", regs_[RISCV64_REG_PC]); | ||
| 208 | + fn("ra", regs_[RISCV64_REG_RA]); | ||
| 209 | + fn("sp", regs_[RISCV64_REG_SP]); | ||
| 210 | + fn("gp", regs_[RISCV64_REG_GP]); | ||
| 211 | + fn("tp", regs_[RISCV64_REG_TP]); | ||
| 212 | + fn("t0", regs_[RISCV64_REG_T0]); | ||
| 213 | + fn("t1", regs_[RISCV64_REG_T1]); | ||
| 214 | + fn("t2", regs_[RISCV64_REG_T2]); | ||
| 215 | + fn("t3", regs_[RISCV64_REG_T3]); | ||
| 216 | + fn("t4", regs_[RISCV64_REG_T4]); | ||
| 217 | + fn("t5", regs_[RISCV64_REG_T5]); | ||
| 218 | + fn("t6", regs_[RISCV64_REG_T6]); | ||
| 219 | + fn("s0", regs_[RISCV64_REG_S0]); | ||
| 220 | + fn("s1", regs_[RISCV64_REG_S1]); | ||
| 221 | + fn("s2", regs_[RISCV64_REG_S2]); | ||
| 222 | + fn("s3", regs_[RISCV64_REG_S3]); | ||
| 223 | + fn("s4", regs_[RISCV64_REG_S4]); | ||
| 224 | + fn("s5", regs_[RISCV64_REG_S5]); | ||
| 225 | + fn("s6", regs_[RISCV64_REG_S6]); | ||
| 226 | + fn("s7", regs_[RISCV64_REG_S7]); | ||
| 227 | + fn("s8", regs_[RISCV64_REG_S8]); | ||
| 228 | + fn("s9", regs_[RISCV64_REG_S9]); | ||
| 229 | + fn("s10", regs_[RISCV64_REG_S10]); | ||
| 230 | + fn("s11", regs_[RISCV64_REG_S11]); | ||
| 231 | + fn("a0", regs_[RISCV64_REG_A0]); | ||
| 232 | + fn("a1", regs_[RISCV64_REG_A1]); | ||
| 233 | + fn("a2", regs_[RISCV64_REG_A2]); | ||
| 234 | + fn("a3", regs_[RISCV64_REG_A3]); | ||
| 235 | + fn("a4", regs_[RISCV64_REG_A4]); | ||
| 236 | + fn("a5", regs_[RISCV64_REG_A5]); | ||
| 237 | + fn("a6", regs_[RISCV64_REG_A6]); | ||
| 238 | + fn("a7", regs_[RISCV64_REG_A7]); | ||
| 239 | +} | ||
| 240 | + | ||
| 241 | +Regs* RegsRiscv64::Read(void* remote_data) { | ||
| 242 | + riscv64_user_regs* user = reinterpret_cast<riscv64_user_regs*>(remote_data); | ||
| 243 | + | ||
| 244 | + RegsRiscv64* regs = new RegsRiscv64(); | ||
| 245 | + memcpy(regs->RawData(), &user->regs[0], RISCV64_REG_MAX * sizeof(uint64_t)); | ||
| 246 | + // uint64_t* reg_data = reinterpret_cast<uint64_t*>(regs->RawData()); | ||
| 247 | + return regs; | ||
| 248 | +} | ||
| 249 | + | ||
| 250 | +Regs* RegsRiscv64::CreateFromUcontext(void* ucontext) { | ||
| 251 | + riscv64_ucontext_t* riscv64_ucontext = reinterpret_cast<riscv64_ucontext_t*>(ucontext); | ||
| 252 | + | ||
| 253 | + RegsRiscv64* regs = new RegsRiscv64(); | ||
| 254 | + memcpy(regs->RawData(), &riscv64_ucontext->uc_mcontext.__gregs[0], | ||
| 255 | + RISCV64_REG_MAX * sizeof(uint64_t)); | ||
| 256 | + return regs; | ||
| 257 | +} | ||
| 258 | + | ||
| 259 | +bool RegsRiscv64::StepIfSignalHandler(uint64_t elf_offset, Elf* elf, Memory* process_memory) { | ||
| 260 | + uint64_t data; | ||
| 261 | + Memory* elf_memory = elf->memory(); | ||
| 262 | + // Read from elf memory since it is usually more expensive to read from | ||
| 263 | + // process memory. | ||
| 264 | + if (!elf_memory->ReadFully(elf_offset, &data, sizeof(data))) { | ||
| 265 | + return false; | ||
| 266 | + } | ||
| 267 | + // Look for the kernel sigreturn function. | ||
| 268 | + // __kernel_rt_sigreturn: | ||
| 269 | + // li a7, __NR_rt_sigreturn | ||
| 270 | + // scall | ||
| 271 | + | ||
| 272 | + const uint8_t li_scall[] = {0x93, 0x08, 0xb0, 0x08, 0x73, 0x00, 0x00, 0x00}; | ||
| 273 | + if (memcmp(&data, &li_scall, 8) != 0) { | ||
| 274 | + return false; | ||
| 275 | + } | ||
| 276 | + | ||
| 277 | + // SP + sizeof(siginfo_t) + uc_mcontext offset + PC offset. | ||
| 278 | + if (!process_memory->ReadFully(regs_[RISCV64_REG_SP] + 0x80 + 0xb0 + 0x00, regs_.data(), | ||
| 279 | + sizeof(uint64_t) * (RISCV64_REG_MAX))) { | ||
| 280 | + return false; | ||
| 281 | + } | ||
| 282 | + return true; | ||
| 283 | +} | ||
| 284 | + | ||
| 285 | +Regs* RegsRiscv64::Clone() { | ||
| 286 | + return new RegsRiscv64(*this); | ||
| 287 | +} | ||
| 288 | + | ||
| 289 | +} // namespace unwindstack | ||
| 290 | diff --git a/system/core/libunwindstack/include/unwindstack/Elf.h b/system/core/libunwindstack/include/unwindstack/Elf.h | ||
| 291 | index 472ed92..88fa0ff 100644 | ||
| 292 | --- a/system/core/libunwindstack/include/unwindstack/Elf.h | ||
| 293 | +++ b/system/core/libunwindstack/include/unwindstack/Elf.h | ||
| 294 | @@ -32,6 +32,10 @@ | ||
| 295 | #define EM_AARCH64 183 | ||
| 296 | #endif | ||
| 297 | |||
| 298 | +#if !defined(EM_RISCV) | ||
| 299 | +#define EM_RISCV 243 | ||
| 300 | +#endif | ||
| 301 | + | ||
| 302 | namespace unwindstack { | ||
| 303 | |||
| 304 | // Forward declaration. | ||
| 305 | @@ -46,6 +50,7 @@ enum ArchEnum : uint8_t { | ||
| 306 | ARCH_X86_64, | ||
| 307 | ARCH_MIPS, | ||
| 308 | ARCH_MIPS64, | ||
| 309 | + ARCH_RISCV64, | ||
| 310 | }; | ||
| 311 | |||
| 312 | class Elf { | ||
| 313 | diff --git a/system/core/libunwindstack/include/unwindstack/MachineRiscv64.h b/system/core/libunwindstack/include/unwindstack/MachineRiscv64.h | ||
| 314 | new file mode 100644 | ||
| 315 | index 0000000..397e680 | ||
| 316 | --- /dev/null | ||
| 317 | +++ b/system/core/libunwindstack/include/unwindstack/MachineRiscv64.h | ||
| 318 | @@ -0,0 +1,59 @@ | ||
| 319 | +/* | ||
| 320 | + * Copyright (C) 2022 The Android Open Source Project | ||
| 321 | + * | ||
| 322 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 323 | + * you may not use this file except in compliance with the License. | ||
| 324 | + * You may obtain a copy of the License at | ||
| 325 | + * | ||
| 326 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
| 327 | + * | ||
| 328 | + * Unless required by applicable law or agreed to in writing, software | ||
| 329 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
| 330 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 331 | + * See the License for the specific language governing permissions and | ||
| 332 | + * limitations under the License. | ||
| 333 | + */ | ||
| 334 | + | ||
| 335 | +#pragma once | ||
| 336 | + | ||
| 337 | +#include <stdint.h> | ||
| 338 | + | ||
| 339 | +namespace unwindstack { | ||
| 340 | + | ||
| 341 | +enum Riscv64Reg : uint16_t { | ||
| 342 | + RISCV64_REG_PC, | ||
| 343 | + RISCV64_REG_RA, | ||
| 344 | + RISCV64_REG_SP, | ||
| 345 | + RISCV64_REG_GP, | ||
| 346 | + RISCV64_REG_TP, | ||
| 347 | + RISCV64_REG_T0, | ||
| 348 | + RISCV64_REG_T1, | ||
| 349 | + RISCV64_REG_T2, | ||
| 350 | + RISCV64_REG_S0, | ||
| 351 | + RISCV64_REG_S1, | ||
| 352 | + RISCV64_REG_A0, | ||
| 353 | + RISCV64_REG_A1, | ||
| 354 | + RISCV64_REG_A2, | ||
| 355 | + RISCV64_REG_A3, | ||
| 356 | + RISCV64_REG_A4, | ||
| 357 | + RISCV64_REG_A5, | ||
| 358 | + RISCV64_REG_A6, | ||
| 359 | + RISCV64_REG_A7, | ||
| 360 | + RISCV64_REG_S2, | ||
| 361 | + RISCV64_REG_S3, | ||
| 362 | + RISCV64_REG_S4, | ||
| 363 | + RISCV64_REG_S5, | ||
| 364 | + RISCV64_REG_S6, | ||
| 365 | + RISCV64_REG_S7, | ||
| 366 | + RISCV64_REG_S8, | ||
| 367 | + RISCV64_REG_S9, | ||
| 368 | + RISCV64_REG_S10, | ||
| 369 | + RISCV64_REG_S11, | ||
| 370 | + RISCV64_REG_T3, | ||
| 371 | + RISCV64_REG_T4, | ||
| 372 | + RISCV64_REG_T5, | ||
| 373 | + RISCV64_REG_T6, | ||
| 374 | + RISCV64_REG_MAX, | ||
| 375 | +}; | ||
| 376 | + | ||
| 377 | +} // namespace unwindstack | ||
| 378 | diff --git a/system/core/libunwindstack/include/unwindstack/RegsGetLocal.h b/system/core/libunwindstack/include/unwindstack/RegsGetLocal.h | ||
| 379 | index f0b5e3a..698eba2 100644 | ||
| 380 | --- a/system/core/libunwindstack/include/unwindstack/RegsGetLocal.h | ||
| 381 | +++ b/system/core/libunwindstack/include/unwindstack/RegsGetLocal.h | ||
| 382 | @@ -81,6 +81,49 @@ inline __attribute__((__always_inline__)) void AsmGetRegs(void* reg_data) { | ||
| 383 | : "x12", "x13", "memory"); | ||
| 384 | } | ||
| 385 | |||
| 386 | +#elif defined(__riscv) | ||
| 387 | + | ||
| 388 | +inline __attribute__((__always_inline__)) void AsmGetRegs(void* reg_data) { | ||
| 389 | + asm volatile( | ||
| 390 | + "1:\n" | ||
| 391 | + "sd ra, 8(%[base])\n" | ||
| 392 | + "sd sp, 16(%[base])\n" | ||
| 393 | + "sd gp, 24(%[base])\n" | ||
| 394 | + "sd tp, 32(%[base])\n" | ||
| 395 | + "sd t0, 40(%[base])\n" | ||
| 396 | + "sd t1, 48(%[base])\n" | ||
| 397 | + "sd t2, 56(%[base])\n" | ||
| 398 | + "sd s0, 64(%[base])\n" | ||
| 399 | + "sd s1, 72(%[base])\n" | ||
| 400 | + "sd a0, 80(%[base])\n" | ||
| 401 | + "sd a1, 88(%[base])\n" | ||
| 402 | + "sd a2, 96(%[base])\n" | ||
| 403 | + "sd a3, 104(%[base])\n" | ||
| 404 | + "sd a4, 112(%[base])\n" | ||
| 405 | + "sd a5, 120(%[base])\n" | ||
| 406 | + "sd a6, 128(%[base])\n" | ||
| 407 | + "sd a7, 136(%[base])\n" | ||
| 408 | + "sd s2, 144(%[base])\n" | ||
| 409 | + "sd s3, 152(%[base])\n" | ||
| 410 | + "sd s4, 160(%[base])\n" | ||
| 411 | + "sd s5, 168(%[base])\n" | ||
| 412 | + "sd s6, 176(%[base])\n" | ||
| 413 | + "sd s7, 184(%[base])\n" | ||
| 414 | + "sd s8, 192(%[base])\n" | ||
| 415 | + "sd s9, 200(%[base])\n" | ||
| 416 | + "sd s10, 208(%[base])\n" | ||
| 417 | + "sd s11, 216(%[base])\n" | ||
| 418 | + "sd t3, 224(%[base])\n" | ||
| 419 | + "sd t4, 232(%[base])\n" | ||
| 420 | + "sd t5, 240(%[base])\n" | ||
| 421 | + "sd t6, 248(%[base])\n" | ||
| 422 | + "la t1, 1b\n" | ||
| 423 | + "sd t1, 0(%[base])\n" | ||
| 424 | + : [base] "+r"(reg_data) | ||
| 425 | + : | ||
| 426 | + : "t1", "memory"); | ||
| 427 | +} | ||
| 428 | + | ||
| 429 | #elif defined(__i386__) || defined(__x86_64__) || defined(__mips__) | ||
| 430 | |||
| 431 | extern "C" void AsmGetRegs(void* regs); | ||
| 432 | diff --git a/system/core/libunwindstack/include/unwindstack/RegsRiscv64.h b/system/core/libunwindstack/include/unwindstack/RegsRiscv64.h | ||
| 433 | new file mode 100644 | ||
| 434 | index 0000000..eb09397 | ||
| 435 | --- /dev/null | ||
| 436 | +++ b/system/core/libunwindstack/include/unwindstack/RegsRiscv64.h | ||
| 437 | @@ -0,0 +1,59 @@ | ||
| 438 | +/* | ||
| 439 | + * Copyright (C) 2022 The Android Open Source Project | ||
| 440 | + * | ||
| 441 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 442 | + * you may not use this file except in compliance with the License. | ||
| 443 | + * You may obtain a copy of the License at | ||
| 444 | + * | ||
| 445 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
| 446 | + * | ||
| 447 | + * Unless required by applicable law or agreed to in writing, software | ||
| 448 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
| 449 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 450 | + * See the License for the specific language governing permissions and | ||
| 451 | + * limitations under the License. | ||
| 452 | + */ | ||
| 453 | + | ||
| 454 | +#pragma once | ||
| 455 | + | ||
| 456 | +#include <stdint.h> | ||
| 457 | + | ||
| 458 | +#include <functional> | ||
| 459 | + | ||
| 460 | +#include <unwindstack/Elf.h> | ||
| 461 | +#include <unwindstack/Regs.h> | ||
| 462 | + | ||
| 463 | +namespace unwindstack { | ||
| 464 | + | ||
| 465 | +// Forward declarations. | ||
| 466 | +class Memory; | ||
| 467 | + | ||
| 468 | +class RegsRiscv64 : public RegsImpl<uint64_t> { | ||
| 469 | + public: | ||
| 470 | + RegsRiscv64(); | ||
| 471 | + virtual ~RegsRiscv64() = default; | ||
| 472 | + | ||
| 473 | + ArchEnum Arch() override final; | ||
| 474 | + | ||
| 475 | + uint64_t GetPcAdjustment(uint64_t rel_pc, Elf* elf) override; | ||
| 476 | + | ||
| 477 | + bool SetPcFromReturnAddress(Memory* process_memory) override; | ||
| 478 | + | ||
| 479 | + bool StepIfSignalHandler(uint64_t elf_offset, Elf* elf, Memory* process_memory) override; | ||
| 480 | + | ||
| 481 | + void IterateRegisters(std::function<void(const char*, uint64_t)>) override final; | ||
| 482 | + | ||
| 483 | + uint64_t pc() override; | ||
| 484 | + uint64_t sp() override; | ||
| 485 | + | ||
| 486 | + void set_pc(uint64_t pc) override; | ||
| 487 | + void set_sp(uint64_t sp) override; | ||
| 488 | + | ||
| 489 | + Regs* Clone() override final; | ||
| 490 | + | ||
| 491 | + static Regs* Read(void* data); | ||
| 492 | + | ||
| 493 | + static Regs* CreateFromUcontext(void* ucontext); | ||
| 494 | +}; | ||
| 495 | + | ||
| 496 | +} // namespace unwindstack | ||
| 497 | diff --git a/system/core/libunwindstack/include/unwindstack/UcontextRiscv64.h b/system/core/libunwindstack/include/unwindstack/UcontextRiscv64.h | ||
| 498 | new file mode 100644 | ||
| 499 | index 0000000..c6c82b1 | ||
| 500 | --- /dev/null | ||
| 501 | +++ b/system/core/libunwindstack/include/unwindstack/UcontextRiscv64.h | ||
| 502 | @@ -0,0 +1,80 @@ | ||
| 503 | +/* | ||
| 504 | + * Copyright (C) 2014 The Android Open Source Project | ||
| 505 | + * All rights reserved. | ||
| 506 | + * | ||
| 507 | + * Redistribution and use in source and binary forms, with or without | ||
| 508 | + * modification, are permitted provided that the following conditions | ||
| 509 | + * are met: | ||
| 510 | + * * Redistributions of source code must retain the above copyright | ||
| 511 | + * notice, this list of conditions and the following disclaimer. | ||
| 512 | + * * Redistributions in binary form must reproduce the above copyright | ||
| 513 | + * notice, this list of conditions and the following disclaimer in | ||
| 514 | + * the documentation and/or other materials provided with the | ||
| 515 | + * distribution. | ||
| 516 | + * | ||
| 517 | + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
| 518 | + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
| 519 | + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS | ||
| 520 | + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE | ||
| 521 | + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, | ||
| 522 | + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, | ||
| 523 | + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS | ||
| 524 | + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED | ||
| 525 | + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | ||
| 526 | + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT | ||
| 527 | + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
| 528 | + * SUCH DAMAGE. | ||
| 529 | + */ | ||
| 530 | + | ||
| 531 | +#pragma once | ||
| 532 | + | ||
| 533 | +#include <sys/cdefs.h> | ||
| 534 | + | ||
| 535 | +typedef uint64_t __riscv_mc_gp_state[32]; // unsigned long | ||
| 536 | + | ||
| 537 | +struct __riscv_mc_f_ext_state { | ||
| 538 | + uint32_t __f[32]; | ||
| 539 | + uint32_t __fcsr; | ||
| 540 | +}; | ||
| 541 | + | ||
| 542 | +struct __riscv_mc_d_ext_state { | ||
| 543 | + uint64_t __f[32]; | ||
| 544 | + uint32_t __fcsr; | ||
| 545 | +}; | ||
| 546 | + | ||
| 547 | +struct __riscv_mc_q_ext_state { | ||
| 548 | + uint64_t __f[64] __attribute__((__aligned__(16))); | ||
| 549 | + uint32_t __fcsr; | ||
| 550 | + uint32_t __reserved[3]; | ||
| 551 | +}; | ||
| 552 | + | ||
| 553 | +union __riscv_mc_fp_state { | ||
| 554 | + struct __riscv_mc_f_ext_state __f; | ||
| 555 | + struct __riscv_mc_d_ext_state __d; | ||
| 556 | + struct __riscv_mc_q_ext_state __q; | ||
| 557 | +}; | ||
| 558 | + | ||
| 559 | +struct __riscv_stack_t { | ||
| 560 | + uint64_t ss_sp; | ||
| 561 | + int32_t ss_flags; | ||
| 562 | + uint64_t ss_size; | ||
| 563 | +}; | ||
| 564 | + | ||
| 565 | +struct riscv64_sigset_t { | ||
| 566 | + uint64_t sig; // unsigned long | ||
| 567 | +}; | ||
| 568 | + | ||
| 569 | +struct riscv64_mcontext_t { | ||
| 570 | + __riscv_mc_gp_state __gregs; | ||
| 571 | + union __riscv_mc_fp_state __fpregs; | ||
| 572 | +}; | ||
| 573 | + | ||
| 574 | +struct riscv64_ucontext_t { | ||
| 575 | + uint64_t uc_flags; // unsigned long | ||
| 576 | + struct riscv64_ucontext_t* uc_link; | ||
| 577 | + __riscv_stack_t uc_stack; | ||
| 578 | + riscv64_sigset_t uc_sigmask; | ||
| 579 | + /* The kernel adds extra padding here to allow sigset_t to grow. */ | ||
| 580 | + int8_t __padding[128 - sizeof(riscv64_sigset_t)]; // char | ||
| 581 | + riscv64_mcontext_t uc_mcontext; | ||
| 582 | +}; | ||
| 583 | diff --git a/system/core/libunwindstack/include/unwindstack/UserRiscv64.h b/system/core/libunwindstack/include/unwindstack/UserRiscv64.h | ||
| 584 | new file mode 100644 | ||
| 585 | index 0000000..1e91228 | ||
| 586 | --- /dev/null | ||
| 587 | +++ b/system/core/libunwindstack/include/unwindstack/UserRiscv64.h | ||
| 588 | @@ -0,0 +1,37 @@ | ||
| 589 | +/* | ||
| 590 | + * Copyright (C) 2016 The Android Open Source Project | ||
| 591 | + * All rights reserved. | ||
| 592 | + * | ||
| 593 | + * Redistribution and use in source and binary forms, with or without | ||
| 594 | + * modification, are permitted provided that the following conditions | ||
| 595 | + * are met: | ||
| 596 | + * * Redistributions of source code must retain the above copyright | ||
| 597 | + * notice, this list of conditions and the following disclaimer. | ||
| 598 | + * * Redistributions in binary form must reproduce the above copyright | ||
| 599 | + * notice, this list of conditions and the following disclaimer in | ||
| 600 | + * the documentation and/or other materials provided with the | ||
| 601 | + * distribution. | ||
| 602 | + * | ||
| 603 | + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
| 604 | + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
| 605 | + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS | ||
| 606 | + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE | ||
| 607 | + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, | ||
| 608 | + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, | ||
| 609 | + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS | ||
| 610 | + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED | ||
| 611 | + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | ||
| 612 | + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT | ||
| 613 | + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
| 614 | + * SUCH DAMAGE. | ||
| 615 | + */ | ||
| 616 | + | ||
| 617 | +#pragma once | ||
| 618 | + | ||
| 619 | +namespace unwindstack { | ||
| 620 | + | ||
| 621 | +struct riscv64_user_regs { | ||
| 622 | + uint64_t regs[32]; | ||
| 623 | +}; | ||
| 624 | + | ||
| 625 | +} // namespace unwindstack | ||
| 626 | diff --git a/system/core/libunwindstack/tools/unwind.cpp b/system/core/libunwindstack/tools/unwind.cpp | ||
| 627 | index 1812e50..ae20891 100644 | ||
| 628 | --- a/system/core/libunwindstack/tools/unwind.cpp | ||
| 629 | +++ b/system/core/libunwindstack/tools/unwind.cpp | ||
| 630 | @@ -83,6 +83,9 @@ void DoUnwind(pid_t pid) { | ||
| 631 | case unwindstack::ARCH_MIPS64: | ||
| 632 | printf("mips64"); | ||
| 633 | break; | ||
| 634 | + case unwindstack::ARCH_RISCV64: | ||
| 635 | + printf("riscv64"); | ||
| 636 | + break; | ||
| 637 | default: | ||
| 638 | printf("unknown\n"); | ||
| 639 | return; | ||
| 640 | diff --git a/system/core/libunwindstack/tools/unwind_symbols.cpp b/system/core/libunwindstack/tools/unwind_symbols.cpp | ||
| 641 | index 8df2284..976db56 100644 | ||
| 642 | --- a/system/core/libunwindstack/tools/unwind_symbols.cpp | ||
| 643 | +++ b/system/core/libunwindstack/tools/unwind_symbols.cpp | ||
| 644 | @@ -77,6 +77,9 @@ int main(int argc, char** argv) { | ||
| 645 | case EM_AARCH64: | ||
| 646 | printf("ABI: arm64\n"); | ||
| 647 | break; | ||
| 648 | + case EM_RISCV: | ||
| 649 | + printf("ABI: riscv64\n"); | ||
| 650 | + break; | ||
| 651 | case EM_386: | ||
| 652 | printf("ABI: x86\n"); | ||
| 653 | 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 @@ | |||
| 1 | Upstream-Status: Pending | ||
| 2 | |||
| 3 | Description: Added missing headers causing compile errors | ||
| 4 | Author: Umang Parmar <umangjparmar@gmail.com> | ||
| 5 | Forwarded: not-needed | ||
| 6 | |||
| 7 | --- a/system/core/adb/sysdeps/posix/network.cpp | ||
| 8 | +++ b/system/core/adb/sysdeps/posix/network.cpp | ||
| 9 | @@ -22,6 +22,7 @@ | ||
| 10 | #include <sys/socket.h> | ||
| 11 | |||
| 12 | #include <string> | ||
| 13 | +#include <cstring> | ||
| 14 | |||
| 15 | #include <android-base/logging.h> | ||
| 16 | #include <android-base/stringprintf.h> | ||
| 17 | --- a/system/core/base/file.cpp | ||
| 18 | +++ b/system/core/base/file.cpp | ||
| 19 | @@ -26,6 +26,7 @@ | ||
| 20 | #include <sys/stat.h> | ||
| 21 | #include <sys/types.h> | ||
| 22 | #include <unistd.h> | ||
| 23 | +#include <cstring> | ||
| 24 | |||
| 25 | #include <memory> | ||
| 26 | #include <mutex> | ||
| 27 | --- a/system/core/libbacktrace/BacktraceMap.cpp | ||
| 28 | +++ b/system/core/libbacktrace/BacktraceMap.cpp | ||
| 29 | @@ -21,6 +21,7 @@ | ||
| 30 | #include <stdint.h> | ||
| 31 | #include <sys/types.h> | ||
| 32 | #include <unistd.h> | ||
| 33 | +#include <algorithm> | ||
| 34 | |||
| 35 | #include <log/log.h> | ||
| 36 | |||
| 37 | --- a/system/core/libbacktrace/UnwindStackMap.cpp | ||
| 38 | +++ b/system/core/libbacktrace/UnwindStackMap.cpp | ||
| 39 | @@ -20,6 +20,7 @@ | ||
| 40 | |||
| 41 | #include <string> | ||
| 42 | #include <vector> | ||
| 43 | +#include <algorithm> | ||
| 44 | |||
| 45 | #include <backtrace/BacktraceMap.h> | ||
| 46 | #include <unwindstack/Elf.h> | ||
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 @@ | |||
| 1 | Upstream-Status: Pending | ||
| 2 | |||
| 3 | Description: Bring Clang's _Nonnull keyword to GCC | ||
| 4 | Author: Kai-Chung Yan | ||
| 5 | Forwarded: not-needed | ||
| 6 | --- a/system/core/adb/sysdeps.h | ||
| 7 | +++ b/system/core/adb/sysdeps.h | ||
| 8 | @@ -40,11 +40,12 @@ | ||
| 9 | #include "sysdeps/network.h" | ||
| 10 | #include "sysdeps/stat.h" | ||
| 11 | |||
| 12 | +#define _Nonnull | ||
| 13 | +#define _Nullable | ||
| 14 | + | ||
| 15 | #ifdef _WIN32 | ||
| 16 | |||
| 17 | // Clang-only nullability specifiers | ||
| 18 | -#define _Nonnull | ||
| 19 | -#define _Nullable | ||
| 20 | |||
| 21 | #include <ctype.h> | ||
| 22 | #include <direct.h> | ||
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 @@ | |||
| 1 | Upstream-Status: Pending | ||
| 2 | |||
| 3 | Description: Fix the weird error by GCC7 that fails to match the correct parent method. | ||
| 4 | Author: Kai-Chung Yan | ||
| 5 | Forwarded: not-needed | ||
| 6 | --- a/system/core/libutils/include/utils/Vector.h | ||
| 7 | +++ b/system/core/libutils/include/utils/Vector.h | ||
| 8 | @@ -256,7 +256,7 @@ | ||
| 9 | |||
| 10 | template<class TYPE> inline | ||
| 11 | const Vector<TYPE>& Vector<TYPE>::operator = (const Vector<TYPE>& rhs) const { | ||
| 12 | - VectorImpl::operator = (static_cast<const VectorImpl&>(rhs)); | ||
| 13 | + VectorImpl::operator = (rhs); | ||
| 14 | return *this; | ||
| 15 | } | ||
| 16 | |||
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 @@ | |||
| 1 | Upstream-Status: Pending | ||
| 2 | |||
| 3 | Forwarded: not-needed | ||
| 4 | --- a/system/core/fs_mgr/liblp/reader.cpp | ||
| 5 | +++ b/system/core/fs_mgr/liblp/reader.cpp | ||
| 6 | @@ -22,6 +22,7 @@ | ||
| 7 | #include <unistd.h> | ||
| 8 | |||
| 9 | #include <functional> | ||
| 10 | +#include <cstring> | ||
| 11 | |||
| 12 | #include <android-base/file.h> | ||
| 13 | #include <android-base/unique_fd.h> | ||
| 14 | --- a/system/core/fs_mgr/liblp/writer.cpp | ||
| 15 | +++ b/system/core/fs_mgr/liblp/writer.cpp | ||
| 16 | @@ -21,6 +21,7 @@ | ||
| 17 | #include <unistd.h> | ||
| 18 | |||
| 19 | #include <string> | ||
| 20 | +#include <cstring> | ||
| 21 | |||
| 22 | #include <android-base/file.h> | ||
| 23 | #include <android-base/unique_fd.h> | ||
| 24 | --- a/system/core/liblog/logger_write.cpp | ||
| 25 | +++ b/system/core/liblog/logger_write.cpp | ||
| 26 | @@ -27,6 +27,7 @@ | ||
| 27 | #include <android/set_abort_message.h> | ||
| 28 | #endif | ||
| 29 | |||
| 30 | +#include <mutex> | ||
| 31 | #include <shared_mutex> | ||
| 32 | |||
| 33 | #include <android-base/errno_restorer.h> | ||
| 34 | --- a/system/core/libziparchive/zip_archive_stream_entry.cc | ||
| 35 | +++ b/system/core/libziparchive/zip_archive_stream_entry.cc | ||
| 36 | @@ -23,6 +23,7 @@ | ||
| 37 | #include <sys/types.h> | ||
| 38 | #include <unistd.h> | ||
| 39 | |||
| 40 | +#include <limits> | ||
| 41 | #include <memory> | ||
| 42 | #include <vector> | ||
| 43 | |||
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 @@ | |||
| 1 | From 72b53f2d5c6e1b462a288cef3d84dd302fe603d6 Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Sasi Kumar Maddineni <quic_sasikuma@quicinc.com> | ||
| 3 | Date: Wed, 29 Oct 2025 11:58:20 +0530 | ||
| 4 | Subject: [PATCH] android-tools: scope 'write' macro to prevent conflict with | ||
| 5 | std::basic_ostream::write | ||
| 6 | |||
| 7 | The build fails with a compiler error due to a macro redefinition of 'write' | ||
| 8 | to '___xxx_write'. This macro substitution interferes with the standard C++ | ||
| 9 | library's definition of std::basic_ostream::write, leading to a mismatch | ||
| 10 | between function declarations and definitions in <ostream.tcc>. | ||
| 11 | |||
| 12 | Wrap the `#undef write` and `#define write ___xxx_write` directives with | ||
| 13 | `#if defined(__ANDROID__)` to ensure they are only applied when building | ||
| 14 | for | ||
| 15 | Android. | ||
| 16 | |||
| 17 | Upstream-Status: Pending | ||
| 18 | |||
| 19 | Signed-off-by: Sasi Kumar Maddineni <quic_sasikuma@quicinc.com> | ||
| 20 | --- | ||
| 21 | system/core/adb/sysdeps.h | 4 ++++ | ||
| 22 | 1 file changed, 4 insertions(+) | ||
| 23 | |||
| 24 | diff --git a/system/core/adb/sysdeps.h b/system/core/adb/sysdeps.h | ||
| 25 | index a4827b8a..ff51d574 100644 | ||
| 26 | --- a/system/core/adb/sysdeps.h | ||
| 27 | +++ b/system/core/adb/sysdeps.h | ||
| 28 | @@ -127,8 +127,10 @@ static __inline__ int unix_read(borrowed_fd fd, void* buf, size_t len) { | ||
| 29 | static __inline__ int unix_write(borrowed_fd fd, const void* buf, size_t len) { | ||
| 30 | return write(fd.get(), buf, len); | ||
| 31 | } | ||
| 32 | +#if defined(__ANDROID__) | ||
| 33 | #undef write | ||
| 34 | #define write ___xxx_write | ||
| 35 | +#endif | ||
| 36 | |||
| 37 | #undef pwrite | ||
| 38 | #define pwrite ___xxx_pwrite | ||
| 39 | @@ -463,8 +465,10 @@ static __inline__ int adb_pwrite(int fd, const void* buf, size_t len, off64_t of | ||
| 40 | #endif | ||
| 41 | } | ||
| 42 | |||
| 43 | +#if defined(__ANDROID__) | ||
| 44 | #undef write | ||
| 45 | #define write ___xxx_write | ||
| 46 | +#endif | ||
| 47 | #undef pwrite | ||
| 48 | #define pwrite ___xxx_pwrite | ||
| 49 | |||
| 50 | -- | ||
| 51 | 2.34.1 | ||
| 52 | |||
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 @@ | |||
| 1 | Upstream-Status: Pending | ||
| 2 | |||
| 3 | Description: remove clang-ism | ||
| 4 | Forwarded: not-needed | ||
| 5 | |||
| 6 | --- a/system/core/base/include/android-base/logging.h | ||
| 7 | +++ b/system/core/base/include/android-base/logging.h | ||
| 8 | @@ -451,10 +451,7 @@ | ||
| 9 | // -Wno-user-defined-warnings to CPPFLAGS. | ||
| 10 | #pragma clang diagnostic push | ||
| 11 | #pragma clang diagnostic ignored "-Wgcc-compat" | ||
| 12 | -#define OSTREAM_STRING_POINTER_USAGE_WARNING \ | ||
| 13 | - __attribute__((diagnose_if(true, "Unexpected logging of string pointer", "warning"))) | ||
| 14 | -inline OSTREAM_STRING_POINTER_USAGE_WARNING | ||
| 15 | -std::ostream& operator<<(std::ostream& stream, const std::string* string_pointer) { | ||
| 16 | +inline std::ostream& operator<<(std::ostream& stream, const std::string* string_pointer) { | ||
| 17 | return stream << static_cast<const void*>(string_pointer); | ||
| 18 | } | ||
| 19 | #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 @@ | |||
| 1 | Upstream-Status: Pending | ||
| 2 | |||
| 3 | Description: non-x86 arches do not have PAGE_SIZE | ||
| 4 | Forwarded: not-needed | ||
| 5 | --- a/system/core/base/cmsg.cpp | ||
| 6 | +++ b/system/core/base/cmsg.cpp | ||
| 7 | @@ -33,7 +33,8 @@ | ||
| 8 | const std::vector<int>& fds) { | ||
| 9 | size_t cmsg_space = CMSG_SPACE(sizeof(int) * fds.size()); | ||
| 10 | size_t cmsg_len = CMSG_LEN(sizeof(int) * fds.size()); | ||
| 11 | - if (cmsg_space >= PAGE_SIZE) { | ||
| 12 | + size_t pagesize = static_cast<size_t>(sysconf(_SC_PAGE_SIZE)); | ||
| 13 | + if (cmsg_space >= pagesize) { | ||
| 14 | errno = ENOMEM; | ||
| 15 | return -1; | ||
| 16 | } | ||
| 17 | @@ -75,7 +76,8 @@ | ||
| 18 | fds->clear(); | ||
| 19 | |||
| 20 | size_t cmsg_space = CMSG_SPACE(sizeof(int) * max_fds); | ||
| 21 | - if (cmsg_space >= PAGE_SIZE) { | ||
| 22 | + size_t pagesize = static_cast<size_t>(sysconf(_SC_PAGE_SIZE)); | ||
| 23 | + if (cmsg_space >= pagesize) { | ||
| 24 | errno = ENOMEM; | ||
| 25 | return -1; | ||
| 26 | } | ||
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 @@ | |||
| 1 | Upstream-Status: Pending | ||
| 2 | |||
| 3 | Description: get libcutils building | ||
| 4 | Forwarded: not-needed | ||
| 5 | --- a/system/core/libcutils/include/cutils/threads.h | ||
| 6 | +++ b/system/core/libcutils/include/cutils/threads.h | ||
| 7 | @@ -33,7 +33,7 @@ | ||
| 8 | // Deprecated: use android::base::GetThreadId instead, which doesn't truncate on Mac/Windows. | ||
| 9 | // | ||
| 10 | |||
| 11 | -extern pid_t gettid(); | ||
| 12 | +extern pid_t gettid(void) __THROW; | ||
| 13 | |||
| 14 | // | ||
| 15 | // Deprecated: use `_Thread_local` in C or `thread_local` in C++. | ||
| 16 | --- a/system/core/libcutils/threads.cpp | ||
| 17 | +++ b/system/core/libcutils/threads.cpp | ||
| 18 | @@ -33,7 +33,7 @@ | ||
| 19 | |||
| 20 | // No definition needed for Android because we'll just pick up bionic's copy. | ||
| 21 | #ifndef __ANDROID__ | ||
| 22 | -pid_t gettid() { | ||
| 23 | +pid_t gettid(void) __THROW { | ||
| 24 | #if defined(__APPLE__) | ||
| 25 | uint64_t tid; | ||
| 26 | 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 @@ | |||
| 1 | Upstream-Status: Pending | ||
| 2 | |||
| 3 | Description: Add missing 'std::' scope identifiers. | ||
| 4 | Forwarded: not-needed | ||
| 5 | --- a/system/core/libunwindstack/include/unwindstack/DwarfMemory.h | ||
| 6 | +++ b/system/core/libunwindstack/include/unwindstack/DwarfMemory.h | ||
| 7 | @@ -29,7 +29,7 @@ | ||
| 8 | DwarfMemory(Memory* memory) : memory_(memory) {} | ||
| 9 | virtual ~DwarfMemory() = default; | ||
| 10 | |||
| 11 | - bool ReadBytes(void* dst, size_t num_bytes); | ||
| 12 | + bool ReadBytes(void* dst, std::size_t num_bytes); | ||
| 13 | |||
| 14 | template <typename SignedType> | ||
| 15 | bool ReadSigned(uint64_t* value); | ||
| 16 | @@ -39,7 +39,7 @@ | ||
| 17 | bool ReadSLEB128(int64_t* value); | ||
| 18 | |||
| 19 | template <typename AddressType> | ||
| 20 | - size_t GetEncodedSize(uint8_t encoding); | ||
| 21 | + std::size_t GetEncodedSize(uint8_t encoding); | ||
| 22 | |||
| 23 | bool AdjustEncodedValue(uint8_t encoding, uint64_t* value); | ||
| 24 | |||
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 @@ | |||
| 1 | Upstream-Status: Pending | ||
| 2 | |||
| 3 | Description: just hard code rather than deal with circular deps | ||
| 4 | Forwarded: not-needed | ||
| 5 | --- a/system/core/adb/adb.cpp | ||
| 6 | +++ b/system/core/adb/adb.cpp | ||
| 7 | @@ -44,8 +44,6 @@ | ||
| 8 | #include <android-base/parsenetaddress.h> | ||
| 9 | #include <android-base/stringprintf.h> | ||
| 10 | #include <android-base/strings.h> | ||
| 11 | -#include <build/version.h> | ||
| 12 | -#include <platform_tools_version.h> | ||
| 13 | |||
| 14 | #include "adb_auth.h" | ||
| 15 | #include "adb_io.h" | ||
| 16 | @@ -69,7 +67,7 @@ | ||
| 17 | "Version %s-%s\n" | ||
| 18 | "Installed as %s\n", | ||
| 19 | ADB_VERSION_MAJOR, ADB_VERSION_MINOR, ADB_SERVER_VERSION, | ||
| 20 | - PLATFORM_TOOLS_VERSION, android::build::GetBuildNumber().c_str(), | ||
| 21 | + PLATFORM_TOOLS_VERSION, "debian", | ||
| 22 | android::base::GetExecutablePath().c_str()); | ||
| 23 | } | ||
| 24 | |||
| 25 | --- a/system/core/fastboot/fastboot.cpp | ||
| 26 | +++ b/system/core/fastboot/fastboot.cpp | ||
| 27 | @@ -59,10 +59,8 @@ | ||
| 28 | #include <android-base/stringprintf.h> | ||
| 29 | #include <android-base/strings.h> | ||
| 30 | #include <android-base/unique_fd.h> | ||
| 31 | -#include <build/version.h> | ||
| 32 | #include <libavb/libavb.h> | ||
| 33 | #include <liblp/liblp.h> | ||
| 34 | -#include <platform_tools_version.h> | ||
| 35 | #include <sparse/sparse.h> | ||
| 36 | #include <ziparchive/zip_archive.h> | ||
| 37 | |||
| 38 | @@ -1680,7 +1678,7 @@ | ||
| 39 | setvbuf(stdout, nullptr, _IONBF, 0); | ||
| 40 | setvbuf(stderr, nullptr, _IONBF, 0); | ||
| 41 | } else if (name == "version") { | ||
| 42 | - fprintf(stdout, "fastboot version %s-%s\n", PLATFORM_TOOLS_VERSION, android::build::GetBuildNumber().c_str()); | ||
| 43 | + fprintf(stdout, "fastboot version %s-%s\n", PLATFORM_TOOLS_VERSION, "debian"); | ||
| 44 | fprintf(stdout, "Installed as %s\n", android::base::GetExecutablePath().c_str()); | ||
| 45 | return 0; | ||
| 46 | #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 @@ | |||
| 1 | Upstream-Status: Pending | ||
| 2 | |||
| 3 | Description: libusb.h comes from different location | ||
| 4 | Author: Umang Parmar <umangjparmar@gmail.com> | ||
| 5 | Forwarded: not-needed | ||
| 6 | Last-Update: 2018-05-26 | ||
| 7 | |||
| 8 | --- a/system/core/adb/client/usb_libusb.cpp | ||
| 9 | +++ b/system/core/adb/client/usb_libusb.cpp | ||
| 10 | @@ -30,7 +30,7 @@ | ||
| 11 | #include <thread> | ||
| 12 | #include <unordered_map> | ||
| 13 | |||
| 14 | -#include <libusb/libusb.h> | ||
| 15 | +#include <libusb-1.0/libusb.h> | ||
| 16 | |||
| 17 | #include <android-base/file.h> | ||
| 18 | #include <android-base/logging.h> | ||
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 @@ | |||
| 1 | From f6874a2f7de30b6eeefb2d509b895c58b93da8f7 Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Sasi Kumar Maddineni <quic_sasikuma@quicinc.com> | ||
| 3 | Date: Wed, 29 Oct 2025 09:38:17 +0530 | ||
| 4 | Subject: [PATCH] libziparchive: fix missing fixed-width integer types in | ||
| 5 | zip_writer.h | ||
| 6 | |||
| 7 | Compilation fails due to undefined types 'uint16_t' and 'uint32_t' in | ||
| 8 | zip_writer.h. These types are used in struct members but are not recognized | ||
| 9 | because the required header <cstdint> is not included. This results in | ||
| 10 | errors such as: | ||
| 11 | error: 'uint16_t' does not name a type | ||
| 12 | error: 'uint32_t' does not name a type | ||
| 13 | |||
| 14 | Added '#include <cstdint>' to zip_writer.h to ensure fixed-width integer | ||
| 15 | types are properly defined. | ||
| 16 | |||
| 17 | Upstream-Status: Pending | ||
| 18 | |||
| 19 | Signed-off-by: Sasi Kumar Maddineni <quic_sasikuma@quicinc.com> | ||
| 20 | --- | ||
| 21 | system/core/libziparchive/include/ziparchive/zip_writer.h | 1 + | ||
| 22 | 1 file changed, 1 insertion(+) | ||
| 23 | |||
| 24 | diff --git a/system/core/libziparchive/include/ziparchive/zip_writer.h b/system/core/libziparchive/include/ziparchive/zip_writer.h | ||
| 25 | index d68683df..7a05e349 100644 | ||
| 26 | --- a/system/core/libziparchive/include/ziparchive/zip_writer.h | ||
| 27 | +++ b/system/core/libziparchive/include/ziparchive/zip_writer.h | ||
| 28 | @@ -18,6 +18,7 @@ | ||
| 29 | |||
| 30 | #include <cstdio> | ||
| 31 | #include <ctime> | ||
| 32 | +#include <cstdint> | ||
| 33 | |||
| 34 | #include <gtest/gtest_prod.h> | ||
| 35 | #include <memory> | ||
| 36 | -- | ||
| 37 | 2.34.1 | ||
| 38 | |||
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 @@ | |||
| 1 | Upstream-Status: Pending | ||
| 2 | |||
| 3 | Description: Update log file directory. | ||
| 4 | Author: Umang Parmar <umangjparmar@gmail.com> | ||
| 5 | Last Updated: 2018-05-17 | ||
| 6 | |||
| 7 | --- a/system/core/adb/adb_utils.cpp | ||
| 8 | +++ b/system/core/adb/adb_utils.cpp | ||
| 9 | @@ -339,6 +339,11 @@ | ||
| 10 | |||
| 11 | return temp_path_utf8 + log_name; | ||
| 12 | #else | ||
| 13 | + std::string log_dir = android::base::StringPrintf("/run/user/%u/adb.log", getuid()); | ||
| 14 | + struct stat st = {0}; | ||
| 15 | + if (stat(log_dir.c_str(), &st) == 0) { | ||
| 16 | + return log_dir; | ||
| 17 | + } | ||
| 18 | const char* tmp_dir = getenv("TMPDIR"); | ||
| 19 | if (tmp_dir == nullptr) tmp_dir = "/tmp"; | ||
| 20 | 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 @@ | |||
| 1 | Description: Port simg_dump to Python 3. | ||
| 2 | Author: Antonio Russo <antonio.e.russo@gmail.com> | ||
| 3 | Forwarded: not-needed | ||
| 4 | Last-Update: 2019-01-05 | ||
| 5 | Origin: https://bugs.debian.org/945646 | ||
| 6 | |||
| 7 | --- | ||
| 8 | Upstream-Status: Pending | ||
| 9 | |||
| 10 | Index: android-platform-tools/system/core/libsparse/simg_dump.py | ||
| 11 | =================================================================== | ||
| 12 | --- android-platform-tools.orig/system/core/libsparse/simg_dump.py | ||
| 13 | +++ android-platform-tools/system/core/libsparse/simg_dump.py | ||
| 14 | @@ -1,4 +1,4 @@ | ||
| 15 | -#! /usr/bin/env python | ||
| 16 | +#! /usr/bin/env python3 | ||
| 17 | |||
| 18 | # Copyright (C) 2012 The Android Open Source Project | ||
| 19 | # | ||
| 20 | @@ -14,7 +14,7 @@ | ||
| 21 | # See the License for the specific language governing permissions and | ||
| 22 | # limitations under the License. | ||
| 23 | |||
| 24 | -from __future__ import print_function | ||
| 25 | + | ||
| 26 | import csv | ||
| 27 | import getopt | ||
| 28 | import hashlib | ||
| 29 | @@ -47,7 +47,7 @@ def main(): | ||
| 30 | opts, args = getopt.getopt(sys.argv[1:], | ||
| 31 | "vsc:", | ||
| 32 | ["verbose", "showhash", "csvfile"]) | ||
| 33 | - except getopt.GetoptError, e: | ||
| 34 | + except getopt.GetoptError as e: | ||
| 35 | print(e) | ||
| 36 | usage(me) | ||
| 37 | for o, a in opts: | ||
| 38 | @@ -66,7 +66,7 @@ def main(): | ||
| 39 | usage(me) | ||
| 40 | |||
| 41 | if csvfilename: | ||
| 42 | - csvfile = open(csvfilename, "wb") | ||
| 43 | + csvfile = open(csvfilename, "w", newline='') | ||
| 44 | csvwriter = csv.writer(csvfile) | ||
| 45 | |||
| 46 | output = verbose or csvfilename or showhash | ||
| 47 | @@ -121,7 +121,7 @@ def main(): | ||
| 48 | "output offset", "output blocks", "type", "hash"]) | ||
| 49 | |||
| 50 | offset = 0 | ||
| 51 | - for i in xrange(1, total_chunks + 1): | ||
| 52 | + for i in range(1, total_chunks + 1): | ||
| 53 | header_bin = FH.read(12) | ||
| 54 | header = struct.unpack("<2H2I", header_bin) | ||
| 55 | chunk_type = header[0] | ||
| 56 | @@ -160,7 +160,7 @@ def main(): | ||
| 57 | if showhash: | ||
| 58 | h = hashlib.sha1() | ||
| 59 | data = fill_bin * (blk_sz / 4); | ||
| 60 | - for block in xrange(chunk_sz): | ||
| 61 | + for block in range(chunk_sz): | ||
| 62 | h.update(data) | ||
| 63 | curhash = h.hexdigest() | ||
| 64 | 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 @@ | |||
| 1 | Upstream-Status: Pending | ||
| 2 | |||
| 3 | Description: Fix incompatibility between <stdatomic.h> and <atomic> | ||
| 4 | This 2 headers combined will cause errors for both GCC and Clang. This patch | ||
| 5 | makes sure only one of them is present at any time. | ||
| 6 | Bug: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60932 | ||
| 7 | Bug: https://reviews.llvm.org/D45470 | ||
| 8 | --- a/system/core/libcutils/include/cutils/trace.h | ||
| 9 | +++ b/system/core/libcutils/include/cutils/trace.h | ||
| 10 | @@ -18,7 +18,14 @@ | ||
| 11 | #define _LIBS_CUTILS_TRACE_H | ||
| 12 | |||
| 13 | #include <inttypes.h> | ||
| 14 | +#ifdef __cplusplus | ||
| 15 | +#include <atomic> | ||
| 16 | +using std::atomic_bool; | ||
| 17 | +using std::atomic_load_explicit; | ||
| 18 | +using std::memory_order_acquire; | ||
| 19 | +#else | ||
| 20 | #include <stdatomic.h> | ||
| 21 | +#endif | ||
| 22 | #include <stdbool.h> | ||
| 23 | #include <stdint.h> | ||
| 24 | #include <stdio.h> | ||
| 25 | --- a/system/core/libcutils/include/cutils/atomic.h | ||
| 26 | +++ b/system/core/libcutils/include/cutils/atomic.h | ||
| 27 | @@ -19,7 +19,23 @@ | ||
| 28 | |||
| 29 | #include <stdint.h> | ||
| 30 | #include <sys/types.h> | ||
| 31 | +#ifdef __cplusplus | ||
| 32 | +#include <atomic> | ||
| 33 | +using std::atomic_compare_exchange_strong_explicit; | ||
| 34 | +using std::atomic_fetch_add_explicit; | ||
| 35 | +using std::atomic_fetch_or_explicit; | ||
| 36 | +using std::atomic_fetch_sub_explicit; | ||
| 37 | +using std::atomic_int_least32_t; | ||
| 38 | +using std::atomic_load_explicit; | ||
| 39 | +using std::atomic_store_explicit; | ||
| 40 | +using std::atomic_thread_fence; | ||
| 41 | +using std::memory_order::memory_order_acquire; | ||
| 42 | +using std::memory_order::memory_order_relaxed; | ||
| 43 | +using std::memory_order::memory_order_release; | ||
| 44 | +using std::memory_order::memory_order_seq_cst; | ||
| 45 | +#else | ||
| 46 | #include <stdatomic.h> | ||
| 47 | +#endif | ||
| 48 | |||
| 49 | #ifndef ANDROID_ATOMIC_INLINE | ||
| 50 | #define ANDROID_ATOMIC_INLINE static inline | ||
| 51 | --- a/system/core/liblog/logger.h | ||
| 52 | +++ b/system/core/liblog/logger.h | ||
| 53 | @@ -16,7 +16,13 @@ | ||
| 54 | |||
| 55 | #pragma once | ||
| 56 | |||
| 57 | +#ifdef __cplusplus | ||
| 58 | +#include <atomic> | ||
| 59 | +using std::atomic_int; | ||
| 60 | +using std::atomic_uintptr_t; | ||
| 61 | +#else | ||
| 62 | #include <stdatomic.h> | ||
| 63 | +#endif | ||
| 64 | #include <sys/cdefs.h> | ||
| 65 | |||
| 66 | #include <log/log.h> | ||
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 @@ | |||
| 1 | Upstream-Status: Pending | ||
| 2 | |||
| 3 | Description: Defer packaging fastdeploy with adb for 29.x.x tags. | ||
| 4 | Forwarded: not-needed | ||
| 5 | --- a/system/core/adb/client/commandline.cpp | ||
| 6 | +++ b/system/core/adb/client/commandline.cpp | ||
| 7 | @@ -59,7 +59,6 @@ | ||
| 8 | #include "bugreport.h" | ||
| 9 | #include "client/file_sync_client.h" | ||
| 10 | #include "commandline.h" | ||
| 11 | -#include "fastdeploy.h" | ||
| 12 | #include "services.h" | ||
| 13 | #include "shell_protocol.h" | ||
| 14 | #include "sysdeps/chrono.h" | ||
| 15 | --- a/system/core/adb/client/adb_install.cpp | ||
| 16 | +++ b/system/core/adb/client/adb_install.cpp | ||
| 17 | @@ -35,7 +35,6 @@ | ||
| 18 | #include "adb_utils.h" | ||
| 19 | #include "client/file_sync_client.h" | ||
| 20 | #include "commandline.h" | ||
| 21 | -#include "fastdeploy.h" | ||
| 22 | |||
| 23 | static constexpr int kFastDeployMinApi = 24; | ||
| 24 | |||
| 25 | @@ -167,14 +166,6 @@ | ||
| 26 | } | ||
| 27 | |||
| 28 | if (use_fastdeploy) { | ||
| 29 | - auto metadata = extract_metadata(file); | ||
| 30 | - if (metadata.has_value()) { | ||
| 31 | - // pass all but 1st (command) and last (apk path) parameters through to pm for | ||
| 32 | - // session creation | ||
| 33 | - std::vector<const char*> pm_args{argv + 1, argv + argc - 1}; | ||
| 34 | - auto patchFd = install_patch(pm_args.size(), pm_args.data()); | ||
| 35 | - return stream_patch(file, std::move(metadata.value()), std::move(patchFd)); | ||
| 36 | - } | ||
| 37 | } | ||
| 38 | |||
| 39 | struct stat sb; | ||
| 40 | @@ -267,16 +258,6 @@ | ||
| 41 | argv[last_apk] = apk_dest.c_str(); /* destination name, not source location */ | ||
| 42 | |||
| 43 | if (use_fastdeploy) { | ||
| 44 | - auto metadata = extract_metadata(apk_file[0]); | ||
| 45 | - if (metadata.has_value()) { | ||
| 46 | - auto patchFd = apply_patch_on_device(apk_dest.c_str()); | ||
| 47 | - int status = stream_patch(apk_file[0], std::move(metadata.value()), std::move(patchFd)); | ||
| 48 | - | ||
| 49 | - result = pm_command(argc, argv); | ||
| 50 | - delete_device_file(apk_dest); | ||
| 51 | - | ||
| 52 | - return status; | ||
| 53 | - } | ||
| 54 | } | ||
| 55 | |||
| 56 | if (do_sync_push(apk_file, apk_dest.c_str(), false)) { | ||
| 57 | @@ -292,7 +273,6 @@ | ||
| 58 | InstallMode installMode = INSTALL_DEFAULT; | ||
| 59 | bool use_fastdeploy = false; | ||
| 60 | bool is_reinstall = false; | ||
| 61 | - FastDeploy_AgentUpdateStrategy agent_update_strategy = FastDeploy_AgentUpdateDifferentVersion; | ||
| 62 | |||
| 63 | for (int i = 1; i < argc; i++) { | ||
| 64 | if (!strcmp(argv[i], "--streaming")) { | ||
| 65 | @@ -313,13 +293,10 @@ | ||
| 66 | use_fastdeploy = false; | ||
| 67 | } else if (!strcmp(argv[i], "--force-agent")) { | ||
| 68 | processedArgIndicies.push_back(i); | ||
| 69 | - agent_update_strategy = FastDeploy_AgentUpdateAlways; | ||
| 70 | } else if (!strcmp(argv[i], "--date-check-agent")) { | ||
| 71 | processedArgIndicies.push_back(i); | ||
| 72 | - agent_update_strategy = FastDeploy_AgentUpdateNewerTimeStamp; | ||
| 73 | } else if (!strcmp(argv[i], "--version-check-agent")) { | ||
| 74 | processedArgIndicies.push_back(i); | ||
| 75 | - agent_update_strategy = FastDeploy_AgentUpdateDifferentVersion; | ||
| 76 | } | ||
| 77 | } | ||
| 78 | |||
| 79 | @@ -331,13 +308,11 @@ | ||
| 80 | error_exit("Attempting to use streaming install on unsupported device"); | ||
| 81 | } | ||
| 82 | |||
| 83 | - if (use_fastdeploy && get_device_api_level() < kFastDeployMinApi) { | ||
| 84 | - printf("Fast Deploy is only compatible with devices of API version %d or higher, " | ||
| 85 | - "ignoring.\n", | ||
| 86 | - kFastDeployMinApi); | ||
| 87 | + if (use_fastdeploy) { | ||
| 88 | + printf("Fast Deploy is unavailable in this build of adb, " | ||
| 89 | + "ignoring.\n"); | ||
| 90 | use_fastdeploy = false; | ||
| 91 | } | ||
| 92 | - fastdeploy_set_agent_update_strategy(agent_update_strategy); | ||
| 93 | |||
| 94 | std::vector<const char*> passthrough_argv; | ||
| 95 | 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 @@ | |||
| 1 | Upstream-Status: Pending | ||
| 2 | |||
| 3 | Description: Turn #error into exceptions | ||
| 4 | So the library can be built on non-Linux platforms too, although can't | ||
| 5 | guarauntee its functionality regarding that piece of code. | ||
| 6 | Forwarded: not-needed | ||
| 7 | --- a/system/core/base/file.cpp | ||
| 8 | +++ b/system/core/base/file.cpp | ||
| 9 | @@ -422,7 +422,8 @@ | ||
| 10 | path[PATH_MAX - 1] = 0; | ||
| 11 | return path; | ||
| 12 | #else | ||
| 13 | -#error unknown OS | ||
| 14 | +#include <stdexcept> | ||
| 15 | + throw std::runtime_error(std::string("Unknown OS!")); | ||
| 16 | #endif | ||
| 17 | } | ||
| 18 | |||
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 @@ | |||
| 1 | Upstream-Status: Pending | ||
| 2 | |||
| 3 | Description: Turn #error into exceptions | ||
| 4 | So the library can be built on non-Linux platforms too, although can't | ||
| 5 | guarauntee its functionality regarding that piece of code. | ||
| 6 | Forwarded: not-needed | ||
| 7 | --- a/system/core/base/file.cpp | ||
| 8 | +++ b/system/core/base/file.cpp | ||
| 9 | @@ -422,7 +422,8 @@ | ||
| 10 | path[PATH_MAX - 1] = 0; | ||
| 11 | return path; | ||
| 12 | #else | ||
| 13 | -#error unknown OS | ||
| 14 | +#include <stdexcept> | ||
| 15 | + throw std::runtime_error(std::string("Unknown OS!")); | ||
| 16 | #endif | ||
| 17 | } | ||
| 18 | |||
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 @@ | |||
| 1 | #!/bin/sh | ||
| 2 | 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 @@ | |||
| 1 | DESCRIPTION = "Various utilities from Android" | ||
| 2 | SECTION = "console/utils" | ||
| 3 | LICENSE = "Apache-2.0 & GPL-2.0-only & BSD-2-Clause & BSD-3-Clause" | ||
| 4 | LIC_FILES_CHKSUM = " \ | ||
| 5 | file://${COMMON_LICENSE_DIR}/Apache-2.0;md5=89aea4e17d99a7cacdbeed46a0096b10 \ | ||
| 6 | file://${COMMON_LICENSE_DIR}/GPL-2.0-only;md5=801f80980d171dd6425610833a22dbe6 \ | ||
| 7 | file://${COMMON_LICENSE_DIR}/BSD-2-Clause;md5=cb641bc04cda31daea161b1bc15da69f \ | ||
| 8 | file://${COMMON_LICENSE_DIR}/BSD-3-Clause;md5=550794465ba0ec5312d6919e203a55f9 \ | ||
| 9 | " | ||
| 10 | DEPENDS = "libbsd libpcre zlib libcap libusb squashfs-tools 7zip libselinux googletest" | ||
| 11 | |||
| 12 | SRCREV_core = "abfd66fafcbb691d7860df059f1df1c9b1ef29da" | ||
| 13 | |||
| 14 | SRC_URI = " \ | ||
| 15 | git://salsa.debian.org/android-tools-team/android-platform-tools;name=core;protocol=https;branch=master \ | ||
| 16 | " | ||
| 17 | |||
| 18 | # Patches copied from android-platform-tools/debian/patches | ||
| 19 | # and applied in the order defined by the file debian/patches/series | ||
| 20 | SRC_URI += " \ | ||
| 21 | file://debian/external/libunwind/user_pt_regs.patch \ | ||
| 22 | file://debian/external/libunwind/legacy_built-in_sync_functions.patch \ | ||
| 23 | file://debian/external/libunwind/20150704-CVE-2015-3239_dwarf_i.h.patch \ | ||
| 24 | file://debian/external/libunwind/libunwind-guard-unreachable-macro-to-avoid-redefinit.patch \ | ||
| 25 | file://debian/external/libunwind/libunwind-fix-strchr-conformance-to-ISO-C23.patch \ | ||
| 26 | \ | ||
| 27 | file://debian/system/core/move-log-file-to-proper-dir.patch \ | ||
| 28 | file://debian/system/core/Added-missing-headers.patch \ | ||
| 29 | file://debian/system/core/libusb-header-path.patch \ | ||
| 30 | file://debian/system/core/stdatomic.patch \ | ||
| 31 | file://debian/system/core/Nonnull.patch \ | ||
| 32 | file://debian/system/core/Vector-cast.patch \ | ||
| 33 | file://debian/system/core/throw-exception-on-unknown-os.patch \ | ||
| 34 | file://debian/system/core/simg_dump-python3.patch \ | ||
| 35 | file://debian/system/core/fix-attribute-issue-with-gcc.patch \ | ||
| 36 | file://debian/system/core/fix-gettid-exception-declaration.patch \ | ||
| 37 | file://debian/system/core/fix-build-on-non-x86.patch \ | ||
| 38 | file://debian/system/core/add-missing-headers.patch \ | ||
| 39 | file://debian/system/core/hard-code-build-number.patch \ | ||
| 40 | file://debian/system/core/stub-out-fastdeploy.patch \ | ||
| 41 | file://debian/system/core/fix-standard-namespace-errors.patch \ | ||
| 42 | file://debian/system/core/Add-riscv64-support.patch \ | ||
| 43 | file://debian/system/core/android-tools-scope-write-macro-to-prevent-conflict-.patch \ | ||
| 44 | file://debian/system/core/libziparchive-fix-missing-fixed-width-integer-types-.patch \ | ||
| 45 | \ | ||
| 46 | " | ||
| 47 | |||
| 48 | # patches which don't come from debian | ||
| 49 | SRC_URI += " \ | ||
| 50 | file://rules_yocto.mk;subdir=${BB_GIT_DEFAULT_DESTSUFFIX} \ | ||
| 51 | file://android-tools-adbd.service \ | ||
| 52 | file://adbd.mk;subdir=${BB_GIT_DEFAULT_DESTSUFFIX}/debian/system/core \ | ||
| 53 | file://remount \ | ||
| 54 | file://0001-Fixes-for-yocto-build.patch \ | ||
| 55 | file://0002-android-tools-modifications-to-make-it-build-in-yoct.patch \ | ||
| 56 | file://0003-Update-usage-of-usbdevfs_urb-to-match-new-kernel-UAP.patch \ | ||
| 57 | file://0004-adb-Fix-build-on-big-endian-systems.patch \ | ||
| 58 | file://0005-adb-Allow-adbd-to-be-run-as-root.patch \ | ||
| 59 | file://0001-liblp-fix-building-with-GCC-14.patch \ | ||
| 60 | " | ||
| 61 | |||
| 62 | B = "${WORKDIR}/${BPN}" | ||
| 63 | |||
| 64 | # http://errors.yoctoproject.org/Errors/Details/1debian881/ | ||
| 65 | ARM_INSTRUCTION_SET:armv4 = "arm" | ||
| 66 | ARM_INSTRUCTION_SET:armv5 = "arm" | ||
| 67 | |||
| 68 | COMPATIBLE_HOST:powerpc = "(null)" | ||
| 69 | COMPATIBLE_HOST:powerpc64 = "(null)" | ||
| 70 | COMPATIBLE_HOST:powerpc64le = "(null)" | ||
| 71 | |||
| 72 | inherit systemd | ||
| 73 | |||
| 74 | SYSTEMD_PACKAGES = "${PN}-adbd" | ||
| 75 | SYSTEMD_SERVICE:${PN}-adbd = "android-tools-adbd.service" | ||
| 76 | |||
| 77 | # Find libbsd headers during native builds | ||
| 78 | CC:append:class-native = " -I${STAGING_INCDIR}" | ||
| 79 | CC:append:class-nativesdk = " -I${STAGING_INCDIR}" | ||
| 80 | |||
| 81 | PREREQUISITE_core = "liblog libbase libsparse liblog libcutils" | ||
| 82 | TOOLS_TO_BUILD = "libcrypto_utils libadb libziparchive fastboot adb img2simg simg2img libbacktrace" | ||
| 83 | TOOLS_TO_BUILD:append:class-target = " adbd" | ||
| 84 | |||
| 85 | do_compile() { | ||
| 86 | |||
| 87 | case "${HOST_ARCH}" in | ||
| 88 | arm) | ||
| 89 | export android_arch=linux-arm | ||
| 90 | cpu=arm | ||
| 91 | deb_host_arch=arm | ||
| 92 | ;; | ||
| 93 | aarch64) | ||
| 94 | export android_arch=linux-arm64 | ||
| 95 | cpu=arm64 | ||
| 96 | deb_host_arch=arm64 | ||
| 97 | ;; | ||
| 98 | riscv64) | ||
| 99 | export android_arch=linux-riscv64 | ||
| 100 | ;; | ||
| 101 | mips|mipsel) | ||
| 102 | export android_arch=linux-mips | ||
| 103 | cpu=mips | ||
| 104 | deb_host_arch=mips | ||
| 105 | ;; | ||
| 106 | mips64|mips64el) | ||
| 107 | export android_arch=linux-mips64 | ||
| 108 | cpu=mips64 | ||
| 109 | deb_host_arch=mips64 | ||
| 110 | ;; | ||
| 111 | powerpc|powerpc64) | ||
| 112 | export android_arch=linux-ppc | ||
| 113 | ;; | ||
| 114 | i586|i686|x86_64) | ||
| 115 | export android_arch=linux-x86 | ||
| 116 | cpu=x86_64 | ||
| 117 | deb_host_arch=amd64 | ||
| 118 | ;; | ||
| 119 | esac | ||
| 120 | |||
| 121 | export SRCDIR=${S} | ||
| 122 | |||
| 123 | oe_runmake -f ${S}/debian/external/boringssl/libcrypto.mk -C ${S} | ||
| 124 | oe_runmake -f ${S}/debian/external/libunwind/libunwind.mk -C ${S} CPU=${cpu} | ||
| 125 | |||
| 126 | for tool in ${PREREQUISITE_core}; do | ||
| 127 | oe_runmake -f ${S}/debian/system/core/${tool}.mk -C ${S} | ||
| 128 | done | ||
| 129 | |||
| 130 | for i in `find ${S}/debian/system/extras/ -name "*.mk"`; do | ||
| 131 | oe_runmake -f $i -C ${S} | ||
| 132 | done | ||
| 133 | |||
| 134 | for tool in ${TOOLS_TO_BUILD}; do | ||
| 135 | if [ "$tool" = "libbacktrace" ]; then | ||
| 136 | oe_runmake -f ${S}/debian/system/core/${tool}.mk -C ${S} DEB_HOST_ARCH=${deb_host_arch} | ||
| 137 | else | ||
| 138 | oe_runmake -f ${S}/debian/system/core/${tool}.mk -C ${S} | ||
| 139 | fi | ||
| 140 | done | ||
| 141 | |||
| 142 | } | ||
| 143 | |||
| 144 | do_install() { | ||
| 145 | install -d ${D}${base_sbindir} | ||
| 146 | install -m 0755 ${UNPACKDIR}/remount -D ${D}${base_sbindir}/remount | ||
| 147 | |||
| 148 | for tool in img2simg simg2img fastboot adbd; do | ||
| 149 | if echo ${TOOLS_TO_BUILD} | grep -q "$tool" ; then | ||
| 150 | install -D -p -m0755 ${S}/debian/out/system/core/$tool ${D}${bindir}/$tool | ||
| 151 | fi | ||
| 152 | done | ||
| 153 | |||
| 154 | # grep adb also matches adbd, so handle adb separately from other tools | ||
| 155 | if echo ${TOOLS_TO_BUILD} | grep -q "adb " ; then | ||
| 156 | install -d ${D}${bindir} | ||
| 157 | install -m0755 ${S}/debian/out/system/core/adb ${D}${bindir} | ||
| 158 | fi | ||
| 159 | |||
| 160 | # Outside the if statement to avoid errors during do_package | ||
| 161 | install -D -p -m0644 ${UNPACKDIR}/android-tools-adbd.service \ | ||
| 162 | ${D}${systemd_unitdir}/system/android-tools-adbd.service | ||
| 163 | |||
| 164 | install -d ${D}${libdir}/android/ | ||
| 165 | install -m0755 ${S}/debian/out/system/core/*.so.* ${D}${libdir}/android/ | ||
| 166 | if echo ${TOOLS_TO_BUILD} | grep -q "mkbootimg" ; then | ||
| 167 | install -d ${D}${bindir} | ||
| 168 | install -m0755 ${B}/mkbootimg/mkbootimg ${D}${bindir} | ||
| 169 | fi | ||
| 170 | } | ||
| 171 | |||
| 172 | PACKAGES =+ "${PN}-fstools ${PN}-adbd" | ||
| 173 | |||
| 174 | RDEPENDS:${BPN} = "${BPN}-conf 7zip" | ||
| 175 | |||
| 176 | FILES:${PN}-adbd = "\ | ||
| 177 | ${bindir}/adbd \ | ||
| 178 | ${systemd_unitdir}/system/android-tools-adbd.service \ | ||
| 179 | " | ||
| 180 | |||
| 181 | FILES:${PN}-fstools = "\ | ||
| 182 | ${bindir}/ext2simg \ | ||
| 183 | ${bindir}/ext4fixup \ | ||
| 184 | ${bindir}/img2simg \ | ||
| 185 | ${bindir}/make_ext4fs \ | ||
| 186 | ${bindir}/simg2img \ | ||
| 187 | ${bindir}/simg2simg \ | ||
| 188 | ${bindir}/simg_dump \ | ||
| 189 | ${bindir}/mkuserimg \ | ||
| 190 | " | ||
| 191 | FILES:${PN} += "${libdir}/android ${libdir}/android/*" | ||
| 192 | |||
| 193 | BBCLASSEXTEND = "native" | ||
