added my Recipes

This commit is contained in:
2024-07-11 14:16:35 +02:00
parent 38bc4f53ac
commit 09b621d929
7118 changed files with 525762 additions and 3 deletions

View File

@@ -0,0 +1,4 @@
[Service]
ExecStartPre=/usr/bin/android-gadget-setup
ExecStartPost=/usr/bin/android-gadget-start
ExecStopPost=/usr/bin/android-gadget-cleanup

View File

@@ -0,0 +1,24 @@
#!/bin/sh
[ -d /sys/kernel/config/usb_gadget ] || exit 0
cd /sys/kernel/config/usb_gadget
cd adb
echo "" > UDC || true
killall adbd || true
umount /dev/usb-ffs/adb
rm configs/c.1/ffs.usb0
rmdir configs/c.1/strings/0x409
rmdir configs/c.1
rmdir functions/ffs.usb0
rmdir strings/0x409
cd ..
rmdir adb

View File

@@ -0,0 +1,35 @@
#!/bin/sh
set -e
manufacturer=RPB
model="Android device"
serial=0123456789ABCDEF
if [ -r /etc/android-gadget-setup.machine ] ; then
. /etc/android-gadget-setup.machine
fi
[ -d /sys/kernel/config/usb_gadget ] || modprobe libcomposite
cd /sys/kernel/config/usb_gadget
[ -d adb ] && /usr/bin/android-gadget-cleanup || true
mkdir adb
cd adb
mkdir configs/c.1
mkdir functions/ffs.usb0
mkdir strings/0x409
mkdir configs/c.1/strings/0x409
echo 0x18d1 > idVendor
echo 0xd002 > idProduct
echo "$serial" > strings/0x409/serialnumber
echo "$manufacturer" > strings/0x409/manufacturer
echo "$model" > strings/0x409/product
echo "Conf 1" > configs/c.1/strings/0x409/configuration
ln -s functions/ffs.usb0 configs/c.1
mkdir -p /dev/usb-ffs/adb
mount -t functionfs usb0 /dev/usb-ffs/adb

View File

@@ -0,0 +1,7 @@
#!/bin/sh
set -e
sleep 3
ls /sys/class/udc/ > /sys/kernel/config/usb_gadget/adb/UDC

View File

@@ -0,0 +1,35 @@
DESCRIPTION = "Various utilities from Android - corresponding configuration files for using ConfigFS"
SECTION = "console/utils"
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
SRC_URI = " \
file://android-gadget-setup \
file://android-gadget-start \
file://android-gadget-cleanup \
file://10-adbd-configfs.conf \
"
PACKAGE_ARCH = "${MACHINE_ARCH}"
do_install() {
install -d ${D}${bindir}
install -m 0755 ${WORKDIR}/android-gadget-setup ${D}${bindir}
install -m 0755 ${WORKDIR}/android-gadget-start ${D}${bindir}
install -m 0755 ${WORKDIR}/android-gadget-cleanup ${D}${bindir}
if [ -r ${WORKDIR}/android-gadget-setup.machine ] ; then
install -d ${D}${sysconfdir}
install -m 0644 ${WORKDIR}/android-gadget-setup.machine ${D}${sysconfdir}
fi
install -d ${D}${systemd_unitdir}/system/android-tools-adbd.service.d
install -m 0644 ${WORKDIR}/10-adbd-configfs.conf ${D}${systemd_unitdir}/system/android-tools-adbd.service.d
}
FILES:${PN} += " \
${systemd_unitdir}/system/ \
"
PROVIDES += "android-tools-conf"
RPROVIDES:${PN} = "android-tools-conf"

View File

@@ -0,0 +1,37 @@
#!/bin/sh
[ ! -e /dev/pts ] && mkdir -p /dev/pts
[ ! -e /dev/pts/0 ] && mount devpts /dev/pts -t devpts
# TODO enable the lines below once we have support for getprop
# retrieve the product info from Android
# manufacturer=$(getprop ro.product.manufacturer Android)
# model=$(getprop ro.product.model Android)
# serial=$(getprop ro.serialno 0123456789ABCDEF)
#below are now needed in order to use FunctionFS for ADB, tested to work with 3.4+ kernels
if grep -q functionfs /proc/filesystems; then
mkdir -p /dev/usb-ffs/adb
mount -t functionfs adb /dev/usb-ffs/adb
#android-gadget-setup doesn't provide below 2 and without them it won't work, so we provide them here.
echo adb > /sys/class/android_usb/android0/f_ffs/aliases
echo ffs > /sys/class/android_usb/android0/functions
fi
manufacturer="$(cat /system/build.prop | grep -o 'ro.product.manufacturer=.*' | cut -d'=' -f 2)"
model="$(cat /system/build.prop | grep -o 'ro.product.model=.*' | cut -d'=' -f 2)"
# get the device serial number from /proc/cmdline directly(since we have no getprop on
# GNU/Linux)
serial="$(cat /proc/cmdline | sed 's/.*androidboot.serialno=//' | sed 's/ .*//')"
echo $serial > /sys/class/android_usb/android0/iSerial
echo $manufacturer > /sys/class/android_usb/android0/iManufacturer
echo $model > /sys/class/android_usb/android0/iProduct
echo "0" > /sys/class/android_usb/android0/enable
echo "18d1" > /sys/class/android_usb/android0/idVendor
echo "D002" > /sys/class/android_usb/android0/idProduct
echo "adb" > /sys/class/android_usb/android0/functions
echo "1" > /sys/class/android_usb/android0/enable
sleep 4

View File

@@ -0,0 +1,18 @@
DESCRIPTION = "Different utilities from Android - corresponding configuration files"
SECTION = "console/utils"
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
SRC_URI = "file://android-gadget-setup"
do_install() {
install -d ${D}${bindir}
install -m 0755 ${WORKDIR}/android-gadget-setup ${D}${bindir}
}
python () {
pn = d.getVar('PN')
profprov = d.getVar("PREFERRED_PROVIDER_" + pn)
if profprov and pn != profprov:
raise bb.parse.SkipRecipe("PREFERRED_PROVIDER_%s set to %s, not %s" % (pn, profprov, pn))
}

View File

@@ -0,0 +1,162 @@
From 5de85f8273c7284aa93e35c40f025d4d43d42df9 Mon Sep 17 00:00:00 2001
From: Etienne Cordonnier <ecordonnier@snap.com>
Date: Thu, 16 Mar 2023 18:59:35 +0100
Subject: [PATCH] Fixes for yocto build
Signed-off-by: JJ Robertson <jrobertson@snapchat.com>
[rebased on version 29]
Signed-off-by: Etienne Cordonnier <ecordonnier@snap.com>
---
system/core/adb/daemon/file_sync_service.cpp | 4 ++--
system/core/adb/daemon/framebuffer_service.h | 2 --
system/core/adb/daemon/main.cpp | 5 +++--
system/core/adb/daemon/restart_service.h | 2 --
system/core/adb/daemon/services.cpp | 6 ++----
system/core/adb/daemon/shell_service.cpp | 5 ++++-
system/core/adb/types.h | 1 +
7 files changed, 12 insertions(+), 13 deletions(-)
diff --git a/system/core/adb/daemon/file_sync_service.cpp b/system/core/adb/daemon/file_sync_service.cpp
index d6af7087..92e7087a 100644
--- a/system/core/adb/daemon/file_sync_service.cpp
+++ b/system/core/adb/daemon/file_sync_service.cpp
@@ -111,7 +111,7 @@ static bool secure_mkdirs(const std::string& path) {
partial_path += path_component;
if (should_use_fs_config(partial_path)) {
- fs_config(partial_path.c_str(), 1, nullptr, &uid, &gid, &mode, &capabilities);
+ // fs_config(partial_path.c_str(), 1, nullptr, &uid, &gid, &mode, &capabilities);
}
if (adb_mkdir(partial_path.c_str(), mode) == -1) {
if (errno != EEXIST) {
@@ -469,7 +469,7 @@ static bool do_send(int s, const std::string& spec, std::vector<char>& buffer) {
uint64_t capabilities = 0;
if (should_use_fs_config(path)) {
unsigned int broken_api_hack = mode;
- fs_config(path.c_str(), 0, nullptr, &uid, &gid, &broken_api_hack, &capabilities);
+ // fs_config(path.c_str(), 0, nullptr, &uid, &gid, &broken_api_hack, &capabilities);
mode = broken_api_hack;
}
diff --git a/system/core/adb/daemon/framebuffer_service.h b/system/core/adb/daemon/framebuffer_service.h
index bab44be3..264da597 100644
--- a/system/core/adb/daemon/framebuffer_service.h
+++ b/system/core/adb/daemon/framebuffer_service.h
@@ -18,6 +18,4 @@
#include "adb_unique_fd.h"
-#if defined(__ANDROID__)
void framebuffer_service(unique_fd fd);
-#endif
diff --git a/system/core/adb/daemon/main.cpp b/system/core/adb/daemon/main.cpp
index 3322574c..e807d13d 100644
--- a/system/core/adb/daemon/main.cpp
+++ b/system/core/adb/daemon/main.cpp
@@ -208,6 +208,9 @@ int adbd_main(int server_port) {
umask(0);
signal(SIGPIPE, SIG_IGN);
+ signal(SIGINT, SIG_DFL);
+ signal(SIGQUIT, SIG_DFL);
+
#if defined(__BIONIC__)
auto fdsan_level = android_fdsan_get_error_level();
@@ -254,13 +257,11 @@ int adbd_main(int server_port) {
bool is_usb = false;
-#if defined(__ANDROID__)
if (access(USB_FFS_ADB_EP0, F_OK) == 0) {
// Listen on USB.
usb_init();
is_usb = true;
}
-#endif
// If one of these properties is set, also listen on that port.
// If one of the properties isn't set and we couldn't listen on usb, listen
diff --git a/system/core/adb/daemon/restart_service.h b/system/core/adb/daemon/restart_service.h
index 19840bd5..7a97614b 100644
--- a/system/core/adb/daemon/restart_service.h
+++ b/system/core/adb/daemon/restart_service.h
@@ -18,9 +18,7 @@
#include "adb_unique_fd.h"
-#if defined(__ANDROID__)
void restart_root_service(unique_fd fd);
void restart_unroot_service(unique_fd fd);
void restart_tcp_service(unique_fd fd, int port);
void restart_usb_service(unique_fd fd);
-#endif
diff --git a/system/core/adb/daemon/services.cpp b/system/core/adb/daemon/services.cpp
index 4ec90d27..d8541c23 100644
--- a/system/core/adb/daemon/services.cpp
+++ b/system/core/adb/daemon/services.cpp
@@ -156,7 +156,7 @@ static void spin_service(unique_fd fd) {
}
#endif
// Fall through
- std::string cmd = "/system/bin/reboot ";
+ std::string cmd = "/sbin/reboot ";
cmd += name;
return StartSubprocess(cmd, nullptr, SubprocessType::kRaw, SubprocessProtocol::kNone);
}
@@ -265,11 +265,10 @@ unique_fd daemon_service_to_fd(std::string_view name, atransport* transport) {
}
#endif
-#if defined(__ANDROID__)
if (name.starts_with("framebuffer:")) {
return create_service_thread("fb", framebuffer_service);
} else if (android::base::ConsumePrefix(&name, "remount:")) {
- std::string cmd = "/system/bin/remount ";
+ std::string cmd = "/sbin/remount ";
cmd += name;
return StartSubprocess(cmd, nullptr, SubprocessType::kRaw, SubprocessProtocol::kNone);
} else if (android::base::ConsumePrefix(&name, "reboot:")) {
@@ -303,7 +302,6 @@ unique_fd daemon_service_to_fd(std::string_view name, atransport* transport) {
} else if (name.starts_with("usb:")) {
return create_service_thread("usb", restart_usb_service);
}
-#endif
if (android::base::ConsumePrefix(&name, "dev:")) {
return unique_fd{unix_open(name, O_RDWR | O_CLOEXEC)};
diff --git a/system/core/adb/daemon/shell_service.cpp b/system/core/adb/daemon/shell_service.cpp
index f62032d0..ebcfe18d 100644
--- a/system/core/adb/daemon/shell_service.cpp
+++ b/system/core/adb/daemon/shell_service.cpp
@@ -273,13 +273,16 @@ bool Subprocess::ForkAndExec(std::string* error) {
env["HOSTNAME"] = GetHostName();
env["LOGNAME"] = pw->pw_name;
env["SHELL"] = pw->pw_shell;
- env["TMPDIR"] = "/data/local/tmp";
env["USER"] = pw->pw_name;
}
if (!terminal_type_.empty()) {
env["TERM"] = terminal_type_;
}
+ if (env.find("PS1") == env.end()) {
+ env["PS1"] = "\\h:\\w\\$ ";
+ }
+
std::vector<std::string> joined_env;
for (const auto& it : env) {
diff --git a/system/core/adb/types.h b/system/core/adb/types.h
index c619fffc..f8e0f521 100644
--- a/system/core/adb/types.h
+++ b/system/core/adb/types.h
@@ -22,6 +22,7 @@
#include <memory>
#include <utility>
#include <vector>
+#include <string.h>
#include <android-base/logging.h>

View File

@@ -0,0 +1,366 @@
From fe211cbc305a9316c1d4da2f086d6a50f1c92188 Mon Sep 17 00:00:00 2001
From: Etienne Cordonnier <ecordonnier@snap.com>
Date: Fri, 17 Mar 2023 10:33:11 +0100
Subject: [PATCH] android-tools: modifications to make it build in yocto
- Fix relocation errors on aarch64, e.g.:
"relocation R_AARCH64_ADR_PREL_PG_HI21 against symbol `_ZTV19SparseFileBufSource' which may bind externally can not be used when making a shared object; recompile with -fPIC"
- use ln -f to avoid error "File exists" on incremental builds
- fix missing headers
Signed-off-by: Etienne Cordonnier <ecordonnier@snap.com>
---
debian/external/boringssl/libcrypto.mk | 1 +
debian/system/core/append2simg.mk | 2 +-
debian/system/core/fastboot.mk | 2 +-
debian/system/core/img2simg.mk | 2 +-
debian/system/core/libbacktrace.mk | 8 ++++----
debian/system/core/libbase.mk | 5 +++--
debian/system/core/libcutils.mk | 5 +++--
debian/system/core/liblog.mk | 3 ++-
debian/system/core/libsparse.mk | 5 +++--
debian/system/core/libutils.mk | 2 +-
debian/system/core/libziparchive.mk | 5 +++--
debian/system/core/simg2img.mk | 2 +-
debian/system/core/simg2simg.mk | 2 +-
frameworks/native/libs/adbd_auth/adbd_auth.cpp | 2 ++
system/core/adb/adb_listeners.cpp | 12 ++++++------
system/core/adb/transport_local.cpp | 2 +-
16 files changed, 34 insertions(+), 26 deletions(-)
diff --git a/debian/external/boringssl/libcrypto.mk b/debian/external/boringssl/libcrypto.mk
index c0ea54f4..b3a77bfd 100644
--- a/debian/external/boringssl/libcrypto.mk
+++ b/debian/external/boringssl/libcrypto.mk
@@ -27,6 +27,7 @@ CPPFLAGS += \
-DBORINGSSL_IMPLEMENTATION \
-DBORINGSSL_SHARED_LIBRARY \
-DOPENSSL_SMALL \
+ -DOPENSSL_NO_ASM \
-Iexternal/boringssl/src/crypto \
-Iexternal/boringssl/src/include \
diff --git a/debian/system/core/append2simg.mk b/debian/system/core/append2simg.mk
index 1599bdb8..598c751d 100644
--- a/debian/system/core/append2simg.mk
+++ b/debian/system/core/append2simg.mk
@@ -11,7 +11,7 @@ CPPFLAGS += \
LDFLAGS += \
-Ldebian/out/system/core \
- -Wl,-rpath=/usr/lib/$(DEB_HOST_MULTIARCH)/android \
+ -Wl,-rpath='$$ORIGIN/../lib/android' \
-lbase \
-llog \
-lpthread \
diff --git a/debian/system/core/fastboot.mk b/debian/system/core/fastboot.mk
index d5c9a285..a59ba1a4 100644
--- a/debian/system/core/fastboot.mk
+++ b/debian/system/core/fastboot.mk
@@ -49,7 +49,7 @@ CPPFLAGS += \
LDFLAGS += \
-Ldebian/out/system/core \
- -Wl,-rpath=/usr/lib/$(DEB_HOST_MULTIARCH)/android \
+ -Wl,-rpath='$$ORIGIN/../lib/android' \
-fuse-ld=gold \
-lbase \
-lcutils \
diff --git a/debian/system/core/img2simg.mk b/debian/system/core/img2simg.mk
index 11adf014..8baf5ba5 100644
--- a/debian/system/core/img2simg.mk
+++ b/debian/system/core/img2simg.mk
@@ -11,7 +11,7 @@ CPPFLAGS += \
LDFLAGS += \
-Ldebian/out/system/core \
- -Wl,-rpath=/usr/lib/$(DEB_HOST_MULTIARCH)/android \
+ -Wl,-rpath='$$ORIGIN/../lib/android' \
-lbase \
-llog \
-lpthread \
diff --git a/debian/system/core/libbacktrace.mk b/debian/system/core/libbacktrace.mk
index e3411d76..86e69874 100644
--- a/debian/system/core/libbacktrace.mk
+++ b/debian/system/core/libbacktrace.mk
@@ -1,3 +1,4 @@
+include rules_yocto.mk
include /usr/share/dpkg/architecture.mk
NAME = libbacktrace
@@ -83,10 +84,9 @@ CPPFLAGS += \
LDFLAGS += \
-L/usr/lib/p7zip \
-Ldebian/out/system/core \
- -Wl,-rpath=/usr/lib/p7zip \
- -Wl,-rpath=/usr/lib/$(DEB_HOST_MULTIARCH)/android \
+ -Wl,-rpath='$$ORIGIN' \
-Wl,-soname,$(NAME).so.0 \
- -l:7z.so \
+ -l7z \
-lbase \
-llog \
-lpthread \
@@ -101,7 +101,7 @@ endif
build: $(OBJECTS_CXX) $(OBJECTS_ASSEMBLY) debian/out/external/libunwind/libunwind.a
mkdir -p debian/out/system/core
$(CXX) $^ -o debian/out/system/core/$(NAME).so.0 $(LDFLAGS)
- cd debian/out/system/core && ln -s $(NAME).so.0 $(NAME).so
+ cd debian/out/system/core && ln -sf $(NAME).so.0 $(NAME).so
$(OBJECTS_CXX): %.o: %.cpp
$(CXX) -c -o $@ $< $(CXXFLAGS) $(CPPFLAGS)
diff --git a/debian/system/core/libbase.mk b/debian/system/core/libbase.mk
index d2b074ba..8a90d6de 100644
--- a/debian/system/core/libbase.mk
+++ b/debian/system/core/libbase.mk
@@ -1,3 +1,4 @@
+include rules_yocto.mk
NAME = libbase
SOURCES = \
@@ -30,7 +31,7 @@ CPPFLAGS += \
LDFLAGS += \
-Ldebian/out/system/core \
- -Wl,-rpath=/usr/lib/$(DEB_HOST_MULTIARCH)/android \
+ -Wl,-rpath='$$ORIGIN' \
-Wl,-soname,$(NAME).so.0 \
-llog \
-lpthread \
@@ -44,7 +45,7 @@ endif
build: $(OBJECTS)
$(CXX) $^ -o debian/out/system/core/$(NAME).so.0 $(LDFLAGS)
- cd debian/out/system/core && ln -s $(NAME).so.0 $(NAME).so
+ cd debian/out/system/core && ln -sf $(NAME).so.0 $(NAME).so
$(OBJECTS): %.o: %.cpp
$(CXX) -c -o $@ $< $(CXXFLAGS) $(CPPFLAGS)
diff --git a/debian/system/core/libcutils.mk b/debian/system/core/libcutils.mk
index 9d928b56..c22b0965 100644
--- a/debian/system/core/libcutils.mk
+++ b/debian/system/core/libcutils.mk
@@ -1,3 +1,4 @@
+include rules_yocto.mk
NAME = libcutils
libcutils_nonwindows_sources = \
@@ -47,7 +48,7 @@ CPPFLAGS += \
LDFLAGS += \
-Ldebian/out/system/core \
- -Wl,-rpath=/usr/lib/$(DEB_HOST_MULTIARCH)/android \
+ -Wl,-rpath='$$ORIGIN' \
-Wl,-soname,$(NAME).so.0 \
-lbase \
-llog \
@@ -56,7 +57,7 @@ LDFLAGS += \
build: $(OBJECTS_C) $(OBJECTS_CXX)
$(CXX) $^ -o debian/out/system/core/$(NAME).so.0 $(LDFLAGS)
- cd debian/out/system/core && ln -s $(NAME).so.0 $(NAME).so
+ cd debian/out/system/core && ln -sf $(NAME).so.0 $(NAME).so
$(OBJECTS_C): %.o: %.c
$(CC) -c -o $@ $< $(CFLAGS) $(CPPFLAGS)
diff --git a/debian/system/core/liblog.mk b/debian/system/core/liblog.mk
index f8c3d7fe..34a07341 100644
--- a/debian/system/core/liblog.mk
+++ b/debian/system/core/liblog.mk
@@ -1,3 +1,4 @@
+include rules_yocto.mk
NAME = liblog
liblog_sources = \
@@ -35,7 +36,7 @@ LDFLAGS += \
build: $(OBJECTS)
mkdir -p debian/out/system/core
$(CXX) $^ -o debian/out/system/core/$(NAME).so.0 $(LDFLAGS)
- cd debian/out/system/core && ln -s $(NAME).so.0 $(NAME).so
+ cd debian/out/system/core && ln -sf $(NAME).so.0 $(NAME).so
$(OBJECTS): %.o: %.cpp
$(CXX) -c -o $@ $< $(CXXFLAGS) $(CPPFLAGS)
diff --git a/debian/system/core/libsparse.mk b/debian/system/core/libsparse.mk
index c2b2694c..2da12b8e 100644
--- a/debian/system/core/libsparse.mk
+++ b/debian/system/core/libsparse.mk
@@ -1,3 +1,4 @@
+include rules_yocto.mk
NAME = libsparse
SOURCES = \
@@ -19,7 +20,7 @@ CPPFLAGS += \
LDFLAGS += \
-Ldebian/out/system/core \
- -Wl,-rpath=/usr/lib/$(DEB_HOST_MULTIARCH)/android \
+ -Wl,-rpath='$$ORIGIN' \
-Wl,-soname,$(NAME).so.0 \
-lbase \
-lz \
@@ -27,7 +28,7 @@ LDFLAGS += \
build: $(OBJECTS)
$(CXX) $^ -o debian/out/system/core/$(NAME).so.0 $(LDFLAGS)
- cd debian/out/system/core && ln -s $(NAME).so.0 $(NAME).so
+ cd debian/out/system/core && ln -sf $(NAME).so.0 $(NAME).so
$(OBJECTS): %.o: %.cpp
$(CXX) -c -o $@ $< $(CXXFLAGS) $(CPPFLAGS)
diff --git a/debian/system/core/libutils.mk b/debian/system/core/libutils.mk
index c37b1d2d..332492c1 100644
--- a/debian/system/core/libutils.mk
+++ b/debian/system/core/libutils.mk
@@ -41,7 +41,7 @@ CPPFLAGS += \
LDFLAGS += \
-Ldebian/out/system/core \
- -Wl,-rpath=/usr/lib/$(DEB_HOST_MULTIARCH)/android \
+ -Wl,-rpath='$$ORIGIN' \
-Wl,-soname,$(NAME).so.0 \
-lbacktrace \
-lcutils \
diff --git a/debian/system/core/libziparchive.mk b/debian/system/core/libziparchive.mk
index 1b286b4e..1b7499be 100644
--- a/debian/system/core/libziparchive.mk
+++ b/debian/system/core/libziparchive.mk
@@ -1,3 +1,4 @@
+include rules_yocto.mk
NAME = libziparchive
SOURCES = \
@@ -19,7 +20,7 @@ CPPFLAGS += \
LDFLAGS += \
-Ldebian/out/system/core \
- -Wl,-rpath=/usr/lib/$(DEB_HOST_MULTIARCH)/android \
+ -Wl,-rpath='$$ORIGIN' \
-Wl,-soname,$(NAME).so.0 \
-lbase \
-llog \
@@ -29,7 +30,7 @@ LDFLAGS += \
build: $(OBJECTS)
$(CXX) $^ -o debian/out/system/core/$(NAME).so.0 $(LDFLAGS)
- cd debian/out/system/core && ln -s $(NAME).so.0 $(NAME).so
+ cd debian/out/system/core && ln -sf $(NAME).so.0 $(NAME).so
$(OBJECTS): %.o: %.cc
$(CXX) -c -o $@ $< $(CXXFLAGS) $(CPPFLAGS)
diff --git a/debian/system/core/simg2img.mk b/debian/system/core/simg2img.mk
index f6e3f59d..df4f44f3 100644
--- a/debian/system/core/simg2img.mk
+++ b/debian/system/core/simg2img.mk
@@ -13,7 +13,7 @@ CPPFLAGS += \
LDFLAGS += \
-Ldebian/out/system/core \
- -Wl,-rpath=/usr/lib/$(DEB_HOST_MULTIARCH)/android \
+ -Wl,-rpath='$$ORIGIN/../lib/android' \
-lbase \
-llog \
-lpthread \
diff --git a/debian/system/core/simg2simg.mk b/debian/system/core/simg2simg.mk
index ed53b04c..646ab030 100644
--- a/debian/system/core/simg2simg.mk
+++ b/debian/system/core/simg2simg.mk
@@ -13,7 +13,7 @@ CPPFLAGS += \
LDFLAGS += \
-Ldebian/out/system/core \
- -Wl,-rpath=/usr/lib/$(DEB_HOST_MULTIARCH)/android \
+ -Wl,-rpath='$$ORIGIN/../lib/android' \
-lbase \
-llog \
-lpthread \
diff --git a/frameworks/native/libs/adbd_auth/adbd_auth.cpp b/frameworks/native/libs/adbd_auth/adbd_auth.cpp
index a9c23110..6ca334ba 100644
--- a/frameworks/native/libs/adbd_auth/adbd_auth.cpp
+++ b/frameworks/native/libs/adbd_auth/adbd_auth.cpp
@@ -23,8 +23,10 @@
#include <sys/eventfd.h>
#include <sys/uio.h>
+#include <atomic>
#include <chrono>
#include <deque>
+#include <optional>
#include <string>
#include <string_view>
#include <tuple>
diff --git a/system/core/adb/adb_listeners.cpp b/system/core/adb/adb_listeners.cpp
index 29909a55..440cdbd4 100644
--- a/system/core/adb/adb_listeners.cpp
+++ b/system/core/adb/adb_listeners.cpp
@@ -109,7 +109,7 @@ static void listener_event_func(int _fd, unsigned ev, void* _l)
}
// Called as a transport disconnect function. |arg| is the raw alistener*.
-static void listener_disconnect(void* arg, atransport*) EXCLUDES(listener_list_mutex) {
+static void listener_disconnect(void* arg, atransport*) {
std::lock_guard<std::mutex> lock(listener_list_mutex);
for (auto iter = listener_list.begin(); iter != listener_list.end(); ++iter) {
if (iter->get() == arg) {
@@ -121,7 +121,7 @@ static void listener_disconnect(void* arg, atransport*) EXCLUDES(listener_list_m
}
// Write the list of current listeners (network redirections) into a string.
-std::string format_listeners() EXCLUDES(listener_list_mutex) {
+std::string format_listeners() {
std::lock_guard<std::mutex> lock(listener_list_mutex);
std::string result;
for (auto& l : listener_list) {
@@ -140,7 +140,7 @@ std::string format_listeners() EXCLUDES(listener_list_mutex) {
}
InstallStatus remove_listener(const char* local_name, atransport* transport)
- EXCLUDES(listener_list_mutex) {
+{
std::lock_guard<std::mutex> lock(listener_list_mutex);
for (auto iter = listener_list.begin(); iter != listener_list.end(); ++iter) {
if (local_name == (*iter)->local_name) {
@@ -151,7 +151,7 @@ InstallStatus remove_listener(const char* local_name, atransport* transport)
return INSTALL_STATUS_LISTENER_NOT_FOUND;
}
-void remove_all_listeners() EXCLUDES(listener_list_mutex) {
+void remove_all_listeners() {
std::lock_guard<std::mutex> lock(listener_list_mutex);
auto iter = listener_list.begin();
while (iter != listener_list.end()) {
@@ -164,7 +164,7 @@ void remove_all_listeners() EXCLUDES(listener_list_mutex) {
}
}
-void close_smartsockets() EXCLUDES(listener_list_mutex) {
+void close_smartsockets() {
std::lock_guard<std::mutex> lock(listener_list_mutex);
auto pred = [](const std::unique_ptr<alistener>& listener) {
return listener->local_name == "*smartsocket*";
@@ -174,7 +174,7 @@ void close_smartsockets() EXCLUDES(listener_list_mutex) {
InstallStatus install_listener(const std::string& local_name, const char* connect_to,
atransport* transport, int no_rebind, int* resolved_tcp_port,
- std::string* error) EXCLUDES(listener_list_mutex) {
+ std::string* error) {
std::lock_guard<std::mutex> lock(listener_list_mutex);
for (auto& l : listener_list) {
if (local_name == l->local_name) {
diff --git a/system/core/adb/transport_local.cpp b/system/core/adb/transport_local.cpp
index c7261860..5988ec4d 100644
--- a/system/core/adb/transport_local.cpp
+++ b/system/core/adb/transport_local.cpp
@@ -333,7 +333,7 @@ struct EmulatorConnection : public FdConnection {
/* Only call this function if you already hold local_transports_lock. */
static atransport* find_emulator_transport_by_adb_port_locked(int adb_port)
- REQUIRES(local_transports_lock) {
+{
auto it = local_transports.find(adb_port);
if (it == local_transports.end()) {
return nullptr;

View File

@@ -0,0 +1,126 @@
From 02b6b6977d80af4b9b806054fadb5a06cedf011d Mon Sep 17 00:00:00 2001
From: Etienne Cordonnier <ecordonnier@snap.com>
Date: Tue, 14 Mar 2023 11:33:50 +0100
Subject: [PATCH] Update usage of usbdevfs_urb to match new kernel UAPI
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Linux kernel API has been changed by commit 94dfc73e7cf4 ("treewide: uapi: Replace zero-length arrays with flexible-array members")
where zero-length array iso_frame_desc in struct usbdevfs_urb was replaced with a proper flexible-array member.
Current USB API usage causes a compilation error at Linux 6.0:
In file included from /home/mae/.cache/kiss/proc/121205/build/android-tools/vendor/adb/client/usb_linux.cpp:28:
/usr/include/linux/usbdevice_fs.h:134:41: error: flexible array member usbdevfs_urb::iso_frame_desc not at end of struct usb_handle
134 | struct usbdevfs_iso_packet_desc iso_frame_desc[];
| ^~~~~~~~~~~~~~
/home/mae/.cache/kiss/proc/121205/build/android-tools/vendor/adb/client/usb_linux.cpp:76:18: note: next member usbdevfs_urb usb_handle::urb_out declared here
76 | usbdevfs_urb urb_out;
| ^~~~~~~
/home/mae/.cache/kiss/proc/121205/build/android-tools/vendor/adb/client/usb_linux.cpp:61:8: note: in the definition of struct usb_handle
61 | struct usb_handle {
| ^~~~~~~~~~
Fix it by using pointers to a struct with flexible-array members.
Current fix works both with the old and the new API.
See https://github.com/nmeum/android-tools/issues/74 for more context.
Tested: built on Linux against kernel 5.19 and 6.0; 'adb shell' over USB
cable
Acked-by: Gustavo A. R. Silva gustavoars@kernel.org
Change-Id: I7f0f7b35d9a3ab980d3520b541b60c7857a6b101
Signed-off-by: Anatol Pomozov <anatol.pomozov@gmail.com>
[Backported on version 10]
Signed-off-by: Etienne Cordonnier <ecordonnier@snap.com>
---
system/core/adb/client/usb_linux.cpp | 24 ++++++++++++++----------
1 file changed, 14 insertions(+), 10 deletions(-)
diff --git a/system/core/adb/client/usb_linux.cpp b/system/core/adb/client/usb_linux.cpp
index 343e7b59..6a4479f3 100644
--- a/system/core/adb/client/usb_linux.cpp
+++ b/system/core/adb/client/usb_linux.cpp
@@ -71,8 +71,8 @@ struct usb_handle : public ::usb_handle {
unsigned zero_mask;
unsigned writeable = 1;
- usbdevfs_urb urb_in;
- usbdevfs_urb urb_out;
+ usbdevfs_urb *urb_in;
+ usbdevfs_urb *urb_out;
bool urb_in_busy = false;
bool urb_out_busy = false;
@@ -305,7 +305,7 @@ static int usb_bulk_write(usb_handle* h, const void* data, int len) {
std::unique_lock<std::mutex> lock(h->mutex);
D("++ usb_bulk_write ++");
- usbdevfs_urb* urb = &h->urb_out;
+ usbdevfs_urb* urb = h->urb_out;
memset(urb, 0, sizeof(*urb));
urb->type = USBDEVFS_URB_TYPE_BULK;
urb->endpoint = h->ep_out;
@@ -344,7 +344,7 @@ static int usb_bulk_read(usb_handle* h, void* data, int len) {
std::unique_lock<std::mutex> lock(h->mutex);
D("++ usb_bulk_read ++");
- usbdevfs_urb* urb = &h->urb_in;
+ usbdevfs_urb* urb = h->urb_in;
memset(urb, 0, sizeof(*urb));
urb->type = USBDEVFS_URB_TYPE_BULK;
urb->endpoint = h->ep_in;
@@ -389,7 +389,7 @@ static int usb_bulk_read(usb_handle* h, void* data, int len) {
}
D("[ urb @%p status = %d, actual = %d ]", out, out->status, out->actual_length);
- if (out == &h->urb_in) {
+ if (out == h->urb_in) {
D("[ reap urb - IN complete ]");
h->urb_in_busy = false;
if (urb->status != 0) {
@@ -398,7 +398,7 @@ static int usb_bulk_read(usb_handle* h, void* data, int len) {
}
return urb->actual_length;
}
- if (out == &h->urb_out) {
+ if (out == h->urb_out) {
D("[ reap urb - OUT compelete ]");
h->urb_out_busy = false;
h->cv.notify_all();
@@ -502,10 +502,10 @@ void usb_kick(usb_handle* h) {
** but this ensures that a reader blocked on REAPURB
** will get unblocked
*/
- ioctl(h->fd, USBDEVFS_DISCARDURB, &h->urb_in);
- ioctl(h->fd, USBDEVFS_DISCARDURB, &h->urb_out);
- h->urb_in.status = -ENODEV;
- h->urb_out.status = -ENODEV;
+ ioctl(h->fd, USBDEVFS_DISCARDURB, h->urb_in);
+ ioctl(h->fd, USBDEVFS_DISCARDURB, h->urb_out);
+ h->urb_in->status = -ENODEV;
+ h->urb_out->status = -ENODEV;
h->urb_in_busy = false;
h->urb_out_busy = false;
h->cv.notify_all();
@@ -521,6 +521,8 @@ int usb_close(usb_handle* h) {
D("-- usb close %p (fd = %d) --", h, h->fd);
+ delete h->urb_in;
+ delete h->urb_out;
delete h;
return 0;
@@ -556,6 +558,8 @@ static void register_device(const char* dev_name, const char* dev_path, unsigned
usb->ep_out = ep_out;
usb->zero_mask = zero_mask;
usb->max_packet_size = max_packet_size;
+ usb->urb_in = new usbdevfs_urb;
+ usb->urb_out = new usbdevfs_urb;
// Initialize mark so we don't get garbage collected after the device scan.
usb->mark = true;

View File

@@ -0,0 +1,48 @@
From e4a29888cb52c1eafd3ab57a6e220b38147ecfbe Mon Sep 17 00:00:00 2001
From: Etienne Cordonnier <ecordonnier@snap.com>
Date: Tue, 14 Mar 2023 13:39:23 +0100
Subject: [PATCH] adb: Fix build on big endian systems
The usb_linux_client.c file defines cpu_to_le16/32 by using the C
library htole16/32 function calls. However, cpu_to_le16/32 are used
when initializing structures, i.e in a context where a function call
is not allowed.
It works fine on little endian systems because htole16/32 are defined
by the C library as no-ops. But on big-endian systems, they are
actually doing something, which might involve calling a function,
causing build failures.
To solve this, we simply open-code cpu_to_le16/32 in a way that allows
them to be used when initializing structures.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
[Forward-ported to version 29]
Signed-off-by: Etienne Cordonnier <ecordonnier@snap.com>
---
system/core/adb/daemon/usb_ffs.cpp | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/system/core/adb/daemon/usb_ffs.cpp b/system/core/adb/daemon/usb_ffs.cpp
index b19fa5d5..ef2291ca 100644
--- a/system/core/adb/daemon/usb_ffs.cpp
+++ b/system/core/adb/daemon/usb_ffs.cpp
@@ -39,8 +39,15 @@
#define USB_EXT_PROP_UNICODE 1
-#define cpu_to_le16(x) htole16(x)
-#define cpu_to_le32(x) htole32(x)
+#if __BYTE_ORDER == __LITTLE_ENDIAN
+# define cpu_to_le16(x) (x)
+# define cpu_to_le32(x) (x)
+#else
+# define cpu_to_le16(x) ((((x) >> 8) & 0xffu) | (((x) & 0xffu) << 8))
+# define cpu_to_le32(x) \
+ ((((x) & 0xff000000u) >> 24) | (((x) & 0x00ff0000u) >> 8) | \
+ (((x) & 0x0000ff00u) << 8) | (((x) & 0x000000ffu) << 24))
+#endif
// clang-format off
struct func_desc {

View File

@@ -0,0 +1,23 @@
From 4ef35041ba5c02df48c31f2382e7c3c4316ad936 Mon Sep 17 00:00:00 2001
From: Etienne Cordonnier <ecordonnier@snap.com>
Date: Tue, 14 Mar 2023 13:53:51 +0100
Subject: [PATCH] adb: Allow adbd to be run as root
Signed-off-by: Etienne Cordonnier <ecordonnier@snap.com>
---
system/core/adb/daemon/main.cpp | 1 +
1 file changed, 1 insertion(+)
diff --git a/system/core/adb/daemon/main.cpp b/system/core/adb/daemon/main.cpp
index e807d13d..309663a2 100644
--- a/system/core/adb/daemon/main.cpp
+++ b/system/core/adb/daemon/main.cpp
@@ -75,6 +75,7 @@ static bool should_drop_capabilities_bounding_set() {
}
static bool should_drop_privileges() {
+ return true;
// "adb root" not allowed, always drop privileges.
if (!ALLOW_ADBD_ROOT && !is_device_unlocked()) return true;

View File

@@ -0,0 +1,87 @@
include rules_yocto.mk
NAME = adbd
SOURCES = \
adb/adbconnection/adbconnection_server.cpp \
adb/daemon/auth.cpp \
adb/daemon/file_sync_service.cpp \
adb/daemon/file_sync_service.h \
adb/daemon/framebuffer_service.cpp \
adb/daemon/framebuffer_service.h \
adb/daemon/jdwp_service.cpp \
adb/daemon/main.cpp \
adb/daemon/restart_service.cpp \
adb/daemon/restart_service.h \
adb/daemon/services.cpp \
adb/daemon/shell_service.cpp \
adb/daemon/shell_service.h \
adb/daemon/usb_ffs.cpp \
adb/daemon/usb_legacy.cpp \
adb/daemon/usb.cpp \
adb/shell_service_protocol.cpp \
adb/adb.cpp \
adb/adb_io.cpp \
adb/adb_listeners.cpp \
adb/adb_trace.cpp \
adb/adb_unique_fd.cpp \
adb/adb_utils.cpp \
adb/fdevent/fdevent.cpp \
adb/fdevent/fdevent_epoll.cpp \
adb/services.cpp \
adb/sockets.cpp \
adb/socket_spec.cpp \
adb/sysdeps/errno.cpp \
adb/sysdeps/posix/network.cpp \
adb/sysdeps_unix.cpp \
adb/transport.cpp \
adb/transport_fd.cpp \
adb/transport_local.cpp \
adb/transport_usb.cpp \
adb/types.cpp \
diagnose_usb/diagnose_usb.cpp \
libasyncio/AsyncIO.cpp \
SOURCES := $(foreach source, $(SOURCES), system/core/$(source))
SOURCES += \
frameworks/native/libs/adbd_auth/adbd_auth.cpp
CXXFLAGS += -std=gnu++20
CPPFLAGS += -Isystem/coreinclude -Isystem/core/adb -Isystem/core/base/include -Idebian/out/system/core -Isystem/tools/mkbootimg/include/bootimg -Isystem/core/fs_mgr/include \
-Isystem/core/fs_mgr/include_fstab \
-DADB_VERSION='"$(DEB_VERSION)"' -D_GNU_SOURCE
LDFLAGS += -Wl,-rpath='$$ORIGIN/../lib/android' -Wl,-rpath-link='$$ORIGIN/../lib/android' \
-lpthread -Ldebian/out/system/core -Ldebian/out/external/boringssl -lbase -lcrypto_utils -l:libcrypto.a -lcutils -llog -lresolv
PAGE_SIZE ?= 4096
CXXFLAGS += -UADB_HOST
CXXFLAGS += -DADB_HOST=0
CXXFLAGS += -DALLOW_ADBD_DISABLE_VERITY
CXXFLAGS += -DALLOW_ADBD_NO_AUTH
CXXFLAGS += -DPLATFORM_TOOLS_VERSION='"28.0.2"'
CXXFLAGS += -Isystem/core/diagnose_usb/include
CXXFLAGS += -Isystem/core/adb/daemon/include
CXXFLAGS += -Isystem/core/adb/adbconnection/include
CXXFLAGS += -Isystem/core/libasyncio/include
CXXFLAGS += -Isystem/core/libcutils/include
CXXFLAGS += -Isystem/core/libcrypto_utils/include
CXXFLAGS += -Isystem/core/liblog/include/
CXXFLAGS += -Isystem/core/libutils/include
CXXFLAGS += -Iframeworks/native/libs/adbd_auth/include
CXXFLAGS += -Wno-c++11-narrowing
CXXFLAGS += -DPAGE_SIZE=$(PAGE_SIZE)
# -latomic should be the last library specified
# https://github.com/android/ndk/issues/589
ifneq ($(filter armel mipsel,$(DEB_HOST_ARCH)),)
LDFLAGS += -latomic
endif
build: $(SOURCES)
mkdir --parents debian/out/system/core
$(CXX) $^ -o debian/out/system/core/adbd $(CXXFLAGS) $(CPPFLAGS) $(LDFLAGS)
clean:
$(RM) debian/out/system/core/adbd

View File

@@ -0,0 +1,13 @@
[Unit]
Description=Android Debug Bridge
ConditionPathExists=/var/usb-debugging-enabled
Before=android-system.service
[Service]
Type=simple
Restart=on-failure
ExecStartPre=-/usr/bin/android-gadget-setup adb
ExecStart=/usr/bin/adbd
[Install]
WantedBy=basic.target

View File

@@ -0,0 +1,651 @@
From: Guo Ren <guoren@linux.alibaba.com>
Date: Wed, 29 Jun 2022 16:46:46 +0800
Subject: Add riscv64 support
This patch contains the dwarf unwind support for 64bit risc-v.
* DwarfCfa.cpp (cfa_def_cfa_register): setup register if CFA_REG is
not setup for riscv64
* Elf.cpp (GetRelPc): convert offset to virtual address for riscv64.
* ElfInterface.cpp (GetVirtAddrFromOffset): New for riscv64.
* RegsRiscv64.cpp (StepIfSignalHandler): Fix signal frame check.
libunwindstack/include/unwindstack/
* ElfInterface.h (GetVirtAddrFromOffset): New for riscv64.
libunwindstack/tests/
* DwarfCfaTest.cpp (cfa_def_cfa_register): ok for riscv64.
* RegsStepIfSignalHandlerTest.cpp (riscv64_step_if_signal_handler): Fix
testcase for riscv64
Test: Builds.
Test: All unit tests pass.
Signed-off-by: Guo Ren <guoren@linux.alibaba.com>
Signed-off-by: Lifang Xia <lifang_xia@linux.alibaba.com>
Signed-off-by: Mao Han <han_mao@linux.alibaba.com>
Change-Id: Ib21ddf23cc83f332af202df7bffcaceec16063e0
---
system/core/libunwindstack/Android.bp | 1 +
system/core/libunwindstack/Elf.cpp | 2 +
system/core/libunwindstack/Regs.cpp | 10 ++
system/core/libunwindstack/RegsRiscv64.cpp | 156 +++++++++++++++++++++
.../core/libunwindstack/include/unwindstack/Elf.h | 5 +
.../include/unwindstack/MachineRiscv64.h | 59 ++++++++
.../include/unwindstack/RegsGetLocal.h | 43 ++++++
.../include/unwindstack/RegsRiscv64.h | 59 ++++++++
.../include/unwindstack/UcontextRiscv64.h | 80 +++++++++++
.../include/unwindstack/UserRiscv64.h | 37 +++++
system/core/libunwindstack/tools/unwind.cpp | 3 +
.../core/libunwindstack/tools/unwind_symbols.cpp | 3 +
12 files changed, 458 insertions(+)
create mode 100644 system/core/libunwindstack/RegsRiscv64.cpp
create mode 100644 system/core/libunwindstack/include/unwindstack/MachineRiscv64.h
create mode 100644 system/core/libunwindstack/include/unwindstack/RegsRiscv64.h
create mode 100644 system/core/libunwindstack/include/unwindstack/UcontextRiscv64.h
create mode 100644 system/core/libunwindstack/include/unwindstack/UserRiscv64.h
diff --git a/system/core/libunwindstack/Android.bp b/system/core/libunwindstack/Android.bp
index 3695f72..f1f9c68 100644
--- a/system/core/libunwindstack/Android.bp
+++ b/system/core/libunwindstack/Android.bp
@@ -70,6 +70,7 @@ cc_library {
"RegsArm64.cpp",
"RegsX86.cpp",
"RegsX86_64.cpp",
+ "RegsRiscv64.cpp",
"RegsMips.cpp",
"RegsMips64.cpp",
"Unwinder.cpp",
diff --git a/system/core/libunwindstack/Elf.cpp b/system/core/libunwindstack/Elf.cpp
index f01b092..3c2088b 100644
--- a/system/core/libunwindstack/Elf.cpp
+++ b/system/core/libunwindstack/Elf.cpp
@@ -290,6 +290,8 @@ ElfInterface* Elf::CreateInterfaceFromMemory(Memory* memory) {
arch_ = ARCH_X86_64;
} else if (e_machine == EM_MIPS) {
arch_ = ARCH_MIPS64;
+ } else if (e_machine == EM_RISCV) {
+ arch_ = ARCH_RISCV64;
} else {
// Unsupported.
ALOGI("64 bit elf that is neither aarch64 nor x86_64 nor mips64: e_machine = %d\n",
diff --git a/system/core/libunwindstack/Regs.cpp b/system/core/libunwindstack/Regs.cpp
index c7dec52..447a554 100644
--- a/system/core/libunwindstack/Regs.cpp
+++ b/system/core/libunwindstack/Regs.cpp
@@ -27,12 +27,14 @@
#include <unwindstack/RegsArm64.h>
#include <unwindstack/RegsMips.h>
#include <unwindstack/RegsMips64.h>
+#include <unwindstack/RegsRiscv64.h>
#include <unwindstack/RegsX86.h>
#include <unwindstack/RegsX86_64.h>
#include <unwindstack/UserArm.h>
#include <unwindstack/UserArm64.h>
#include <unwindstack/UserMips.h>
#include <unwindstack/UserMips64.h>
+#include <unwindstack/UserRiscv64.h>
#include <unwindstack/UserX86.h>
#include <unwindstack/UserX86_64.h>
@@ -67,6 +69,8 @@ Regs* Regs::RemoteGet(pid_t pid) {
return RegsMips::Read(buffer.data());
case sizeof(mips64_user_regs):
return RegsMips64::Read(buffer.data());
+ case sizeof(riscv64_user_regs):
+ return RegsRiscv64::Read(buffer.data());
}
return nullptr;
}
@@ -85,6 +89,8 @@ Regs* Regs::CreateFromUcontext(ArchEnum arch, void* ucontext) {
return RegsMips::CreateFromUcontext(ucontext);
case ARCH_MIPS64:
return RegsMips64::CreateFromUcontext(ucontext);
+ case ARCH_RISCV64:
+ return RegsRiscv64::CreateFromUcontext(ucontext);
case ARCH_UNKNOWN:
default:
return nullptr;
@@ -104,6 +110,8 @@ ArchEnum Regs::CurrentArch() {
return ARCH_MIPS;
#elif defined(__mips__) && defined(__LP64__)
return ARCH_MIPS64;
+#elif defined(__riscv)
+ return ARCH_RISCV64;
#else
abort();
#endif
@@ -123,6 +131,8 @@ Regs* Regs::CreateFromLocal() {
regs = new RegsMips();
#elif defined(__mips__) && defined(__LP64__)
regs = new RegsMips64();
+#elif defined(__riscv)
+ regs = new RegsRiscv64();
#else
abort();
#endif
diff --git a/system/core/libunwindstack/RegsRiscv64.cpp b/system/core/libunwindstack/RegsRiscv64.cpp
new file mode 100644
index 0000000..887762a
--- /dev/null
+++ b/system/core/libunwindstack/RegsRiscv64.cpp
@@ -0,0 +1,156 @@
+/*
+ * Copyright (C) 2022 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdint.h>
+#include <string.h>
+
+#include <functional>
+
+#include <unwindstack/Elf.h>
+#include <unwindstack/MachineRiscv64.h>
+#include <unwindstack/MapInfo.h>
+#include <unwindstack/Memory.h>
+#include <unwindstack/RegsRiscv64.h>
+#include <unwindstack/UcontextRiscv64.h>
+#include <unwindstack/UserRiscv64.h>
+
+namespace unwindstack {
+
+RegsRiscv64::RegsRiscv64()
+ : RegsImpl<uint64_t>(RISCV64_REG_MAX, Location(LOCATION_REGISTER, RISCV64_REG_RA)) {}
+
+ArchEnum RegsRiscv64::Arch() {
+ return ARCH_RISCV64;
+}
+
+uint64_t RegsRiscv64::pc() {
+ return regs_[RISCV64_REG_PC];
+}
+
+uint64_t RegsRiscv64::sp() {
+ return regs_[RISCV64_REG_SP];
+}
+
+void RegsRiscv64::set_pc(uint64_t pc) {
+ regs_[RISCV64_REG_PC] = pc;
+}
+
+void RegsRiscv64::set_sp(uint64_t sp) {
+ regs_[RISCV64_REG_SP] = sp;
+}
+
+uint64_t RegsRiscv64::GetPcAdjustment(uint64_t rel_pc, Elf*) {
+ if (rel_pc < 8) {
+ return 0;
+ }
+ // For now, just assume no compact branches
+ return 8;
+}
+
+bool RegsRiscv64::SetPcFromReturnAddress(Memory*) {
+ uint64_t ra = regs_[RISCV64_REG_RA];
+ if (regs_[RISCV64_REG_PC] == ra) {
+ return false;
+ }
+
+ regs_[RISCV64_REG_PC] = ra;
+ return true;
+}
+
+void RegsRiscv64::IterateRegisters(std::function<void(const char*, uint64_t)> fn) {
+ fn("pc", regs_[RISCV64_REG_PC]);
+ fn("ra", regs_[RISCV64_REG_RA]);
+ fn("sp", regs_[RISCV64_REG_SP]);
+ fn("gp", regs_[RISCV64_REG_GP]);
+ fn("tp", regs_[RISCV64_REG_TP]);
+ fn("t0", regs_[RISCV64_REG_T0]);
+ fn("t1", regs_[RISCV64_REG_T1]);
+ fn("t2", regs_[RISCV64_REG_T2]);
+ fn("t3", regs_[RISCV64_REG_T3]);
+ fn("t4", regs_[RISCV64_REG_T4]);
+ fn("t5", regs_[RISCV64_REG_T5]);
+ fn("t6", regs_[RISCV64_REG_T6]);
+ fn("s0", regs_[RISCV64_REG_S0]);
+ fn("s1", regs_[RISCV64_REG_S1]);
+ fn("s2", regs_[RISCV64_REG_S2]);
+ fn("s3", regs_[RISCV64_REG_S3]);
+ fn("s4", regs_[RISCV64_REG_S4]);
+ fn("s5", regs_[RISCV64_REG_S5]);
+ fn("s6", regs_[RISCV64_REG_S6]);
+ fn("s7", regs_[RISCV64_REG_S7]);
+ fn("s8", regs_[RISCV64_REG_S8]);
+ fn("s9", regs_[RISCV64_REG_S9]);
+ fn("s10", regs_[RISCV64_REG_S10]);
+ fn("s11", regs_[RISCV64_REG_S11]);
+ fn("a0", regs_[RISCV64_REG_A0]);
+ fn("a1", regs_[RISCV64_REG_A1]);
+ fn("a2", regs_[RISCV64_REG_A2]);
+ fn("a3", regs_[RISCV64_REG_A3]);
+ fn("a4", regs_[RISCV64_REG_A4]);
+ fn("a5", regs_[RISCV64_REG_A5]);
+ fn("a6", regs_[RISCV64_REG_A6]);
+ fn("a7", regs_[RISCV64_REG_A7]);
+}
+
+Regs* RegsRiscv64::Read(void* remote_data) {
+ riscv64_user_regs* user = reinterpret_cast<riscv64_user_regs*>(remote_data);
+
+ RegsRiscv64* regs = new RegsRiscv64();
+ memcpy(regs->RawData(), &user->regs[0], RISCV64_REG_MAX * sizeof(uint64_t));
+ // uint64_t* reg_data = reinterpret_cast<uint64_t*>(regs->RawData());
+ return regs;
+}
+
+Regs* RegsRiscv64::CreateFromUcontext(void* ucontext) {
+ riscv64_ucontext_t* riscv64_ucontext = reinterpret_cast<riscv64_ucontext_t*>(ucontext);
+
+ RegsRiscv64* regs = new RegsRiscv64();
+ memcpy(regs->RawData(), &riscv64_ucontext->uc_mcontext.__gregs[0],
+ RISCV64_REG_MAX * sizeof(uint64_t));
+ return regs;
+}
+
+bool RegsRiscv64::StepIfSignalHandler(uint64_t elf_offset, Elf* elf, Memory* process_memory) {
+ uint64_t data;
+ Memory* elf_memory = elf->memory();
+ // Read from elf memory since it is usually more expensive to read from
+ // process memory.
+ if (!elf_memory->ReadFully(elf_offset, &data, sizeof(data))) {
+ return false;
+ }
+ // Look for the kernel sigreturn function.
+ // __kernel_rt_sigreturn:
+ // li a7, __NR_rt_sigreturn
+ // scall
+
+ const uint8_t li_scall[] = {0x93, 0x08, 0xb0, 0x08, 0x73, 0x00, 0x00, 0x00};
+ if (memcmp(&data, &li_scall, 8) != 0) {
+ return false;
+ }
+
+ // SP + sizeof(siginfo_t) + uc_mcontext offset + PC offset.
+ if (!process_memory->ReadFully(regs_[RISCV64_REG_SP] + 0x80 + 0xb0 + 0x00, regs_.data(),
+ sizeof(uint64_t) * (RISCV64_REG_MAX))) {
+ return false;
+ }
+ return true;
+}
+
+Regs* RegsRiscv64::Clone() {
+ return new RegsRiscv64(*this);
+}
+
+} // namespace unwindstack
diff --git a/system/core/libunwindstack/include/unwindstack/Elf.h b/system/core/libunwindstack/include/unwindstack/Elf.h
index 472ed92..88fa0ff 100644
--- a/system/core/libunwindstack/include/unwindstack/Elf.h
+++ b/system/core/libunwindstack/include/unwindstack/Elf.h
@@ -32,6 +32,10 @@
#define EM_AARCH64 183
#endif
+#if !defined(EM_RISCV)
+#define EM_RISCV 243
+#endif
+
namespace unwindstack {
// Forward declaration.
@@ -46,6 +50,7 @@ enum ArchEnum : uint8_t {
ARCH_X86_64,
ARCH_MIPS,
ARCH_MIPS64,
+ ARCH_RISCV64,
};
class Elf {
diff --git a/system/core/libunwindstack/include/unwindstack/MachineRiscv64.h b/system/core/libunwindstack/include/unwindstack/MachineRiscv64.h
new file mode 100644
index 0000000..397e680
--- /dev/null
+++ b/system/core/libunwindstack/include/unwindstack/MachineRiscv64.h
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2022 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#pragma once
+
+#include <stdint.h>
+
+namespace unwindstack {
+
+enum Riscv64Reg : uint16_t {
+ RISCV64_REG_PC,
+ RISCV64_REG_RA,
+ RISCV64_REG_SP,
+ RISCV64_REG_GP,
+ RISCV64_REG_TP,
+ RISCV64_REG_T0,
+ RISCV64_REG_T1,
+ RISCV64_REG_T2,
+ RISCV64_REG_S0,
+ RISCV64_REG_S1,
+ RISCV64_REG_A0,
+ RISCV64_REG_A1,
+ RISCV64_REG_A2,
+ RISCV64_REG_A3,
+ RISCV64_REG_A4,
+ RISCV64_REG_A5,
+ RISCV64_REG_A6,
+ RISCV64_REG_A7,
+ RISCV64_REG_S2,
+ RISCV64_REG_S3,
+ RISCV64_REG_S4,
+ RISCV64_REG_S5,
+ RISCV64_REG_S6,
+ RISCV64_REG_S7,
+ RISCV64_REG_S8,
+ RISCV64_REG_S9,
+ RISCV64_REG_S10,
+ RISCV64_REG_S11,
+ RISCV64_REG_T3,
+ RISCV64_REG_T4,
+ RISCV64_REG_T5,
+ RISCV64_REG_T6,
+ RISCV64_REG_MAX,
+};
+
+} // namespace unwindstack
diff --git a/system/core/libunwindstack/include/unwindstack/RegsGetLocal.h b/system/core/libunwindstack/include/unwindstack/RegsGetLocal.h
index f0b5e3a..698eba2 100644
--- a/system/core/libunwindstack/include/unwindstack/RegsGetLocal.h
+++ b/system/core/libunwindstack/include/unwindstack/RegsGetLocal.h
@@ -81,6 +81,49 @@ inline __attribute__((__always_inline__)) void AsmGetRegs(void* reg_data) {
: "x12", "x13", "memory");
}
+#elif defined(__riscv)
+
+inline __attribute__((__always_inline__)) void AsmGetRegs(void* reg_data) {
+ asm volatile(
+ "1:\n"
+ "sd ra, 8(%[base])\n"
+ "sd sp, 16(%[base])\n"
+ "sd gp, 24(%[base])\n"
+ "sd tp, 32(%[base])\n"
+ "sd t0, 40(%[base])\n"
+ "sd t1, 48(%[base])\n"
+ "sd t2, 56(%[base])\n"
+ "sd s0, 64(%[base])\n"
+ "sd s1, 72(%[base])\n"
+ "sd a0, 80(%[base])\n"
+ "sd a1, 88(%[base])\n"
+ "sd a2, 96(%[base])\n"
+ "sd a3, 104(%[base])\n"
+ "sd a4, 112(%[base])\n"
+ "sd a5, 120(%[base])\n"
+ "sd a6, 128(%[base])\n"
+ "sd a7, 136(%[base])\n"
+ "sd s2, 144(%[base])\n"
+ "sd s3, 152(%[base])\n"
+ "sd s4, 160(%[base])\n"
+ "sd s5, 168(%[base])\n"
+ "sd s6, 176(%[base])\n"
+ "sd s7, 184(%[base])\n"
+ "sd s8, 192(%[base])\n"
+ "sd s9, 200(%[base])\n"
+ "sd s10, 208(%[base])\n"
+ "sd s11, 216(%[base])\n"
+ "sd t3, 224(%[base])\n"
+ "sd t4, 232(%[base])\n"
+ "sd t5, 240(%[base])\n"
+ "sd t6, 248(%[base])\n"
+ "la t1, 1b\n"
+ "sd t1, 0(%[base])\n"
+ : [base] "+r"(reg_data)
+ :
+ : "t1", "memory");
+}
+
#elif defined(__i386__) || defined(__x86_64__) || defined(__mips__)
extern "C" void AsmGetRegs(void* regs);
diff --git a/system/core/libunwindstack/include/unwindstack/RegsRiscv64.h b/system/core/libunwindstack/include/unwindstack/RegsRiscv64.h
new file mode 100644
index 0000000..eb09397
--- /dev/null
+++ b/system/core/libunwindstack/include/unwindstack/RegsRiscv64.h
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2022 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#pragma once
+
+#include <stdint.h>
+
+#include <functional>
+
+#include <unwindstack/Elf.h>
+#include <unwindstack/Regs.h>
+
+namespace unwindstack {
+
+// Forward declarations.
+class Memory;
+
+class RegsRiscv64 : public RegsImpl<uint64_t> {
+ public:
+ RegsRiscv64();
+ virtual ~RegsRiscv64() = default;
+
+ ArchEnum Arch() override final;
+
+ uint64_t GetPcAdjustment(uint64_t rel_pc, Elf* elf) override;
+
+ bool SetPcFromReturnAddress(Memory* process_memory) override;
+
+ bool StepIfSignalHandler(uint64_t elf_offset, Elf* elf, Memory* process_memory) override;
+
+ void IterateRegisters(std::function<void(const char*, uint64_t)>) override final;
+
+ uint64_t pc() override;
+ uint64_t sp() override;
+
+ void set_pc(uint64_t pc) override;
+ void set_sp(uint64_t sp) override;
+
+ Regs* Clone() override final;
+
+ static Regs* Read(void* data);
+
+ static Regs* CreateFromUcontext(void* ucontext);
+};
+
+} // namespace unwindstack
diff --git a/system/core/libunwindstack/include/unwindstack/UcontextRiscv64.h b/system/core/libunwindstack/include/unwindstack/UcontextRiscv64.h
new file mode 100644
index 0000000..c6c82b1
--- /dev/null
+++ b/system/core/libunwindstack/include/unwindstack/UcontextRiscv64.h
@@ -0,0 +1,80 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#pragma once
+
+#include <sys/cdefs.h>
+
+typedef uint64_t __riscv_mc_gp_state[32]; // unsigned long
+
+struct __riscv_mc_f_ext_state {
+ uint32_t __f[32];
+ uint32_t __fcsr;
+};
+
+struct __riscv_mc_d_ext_state {
+ uint64_t __f[32];
+ uint32_t __fcsr;
+};
+
+struct __riscv_mc_q_ext_state {
+ uint64_t __f[64] __attribute__((__aligned__(16)));
+ uint32_t __fcsr;
+ uint32_t __reserved[3];
+};
+
+union __riscv_mc_fp_state {
+ struct __riscv_mc_f_ext_state __f;
+ struct __riscv_mc_d_ext_state __d;
+ struct __riscv_mc_q_ext_state __q;
+};
+
+struct __riscv_stack_t {
+ uint64_t ss_sp;
+ int32_t ss_flags;
+ uint64_t ss_size;
+};
+
+struct riscv64_sigset_t {
+ uint64_t sig; // unsigned long
+};
+
+struct riscv64_mcontext_t {
+ __riscv_mc_gp_state __gregs;
+ union __riscv_mc_fp_state __fpregs;
+};
+
+struct riscv64_ucontext_t {
+ uint64_t uc_flags; // unsigned long
+ struct riscv64_ucontext_t* uc_link;
+ __riscv_stack_t uc_stack;
+ riscv64_sigset_t uc_sigmask;
+ /* The kernel adds extra padding here to allow sigset_t to grow. */
+ int8_t __padding[128 - sizeof(riscv64_sigset_t)]; // char
+ riscv64_mcontext_t uc_mcontext;
+};
diff --git a/system/core/libunwindstack/include/unwindstack/UserRiscv64.h b/system/core/libunwindstack/include/unwindstack/UserRiscv64.h
new file mode 100644
index 0000000..1e91228
--- /dev/null
+++ b/system/core/libunwindstack/include/unwindstack/UserRiscv64.h
@@ -0,0 +1,37 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#pragma once
+
+namespace unwindstack {
+
+struct riscv64_user_regs {
+ uint64_t regs[32];
+};
+
+} // namespace unwindstack
diff --git a/system/core/libunwindstack/tools/unwind.cpp b/system/core/libunwindstack/tools/unwind.cpp
index 1812e50..ae20891 100644
--- a/system/core/libunwindstack/tools/unwind.cpp
+++ b/system/core/libunwindstack/tools/unwind.cpp
@@ -83,6 +83,9 @@ void DoUnwind(pid_t pid) {
case unwindstack::ARCH_MIPS64:
printf("mips64");
break;
+ case unwindstack::ARCH_RISCV64:
+ printf("riscv64");
+ break;
default:
printf("unknown\n");
return;
diff --git a/system/core/libunwindstack/tools/unwind_symbols.cpp b/system/core/libunwindstack/tools/unwind_symbols.cpp
index 8df2284..976db56 100644
--- a/system/core/libunwindstack/tools/unwind_symbols.cpp
+++ b/system/core/libunwindstack/tools/unwind_symbols.cpp
@@ -77,6 +77,9 @@ int main(int argc, char** argv) {
case EM_AARCH64:
printf("ABI: arm64\n");
break;
+ case EM_RISCV:
+ printf("ABI: riscv64\n");
+ break;
case EM_386:
printf("ABI: x86\n");
break;

View File

@@ -0,0 +1,44 @@
Description: Added missing headers causing compile errors
Author: Umang Parmar <umangjparmar@gmail.com>
Forwarded: not-needed
--- a/system/core/adb/sysdeps/posix/network.cpp
+++ b/system/core/adb/sysdeps/posix/network.cpp
@@ -22,6 +22,7 @@
#include <sys/socket.h>
#include <string>
+#include <cstring>
#include <android-base/logging.h>
#include <android-base/stringprintf.h>
--- a/system/core/base/file.cpp
+++ b/system/core/base/file.cpp
@@ -26,6 +26,7 @@
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
+#include <cstring>
#include <memory>
#include <mutex>
--- a/system/core/libbacktrace/BacktraceMap.cpp
+++ b/system/core/libbacktrace/BacktraceMap.cpp
@@ -21,6 +21,7 @@
#include <stdint.h>
#include <sys/types.h>
#include <unistd.h>
+#include <algorithm>
#include <log/log.h>
--- a/system/core/libbacktrace/UnwindStackMap.cpp
+++ b/system/core/libbacktrace/UnwindStackMap.cpp
@@ -20,6 +20,7 @@
#include <string>
#include <vector>
+#include <algorithm>
#include <backtrace/BacktraceMap.h>
#include <unwindstack/Elf.h>

View File

@@ -0,0 +1,20 @@
Description: Bring Clang's _Nonnull keyword to GCC
Author: Kai-Chung Yan
Forwarded: not-needed
--- a/system/core/adb/sysdeps.h
+++ b/system/core/adb/sysdeps.h
@@ -40,11 +40,12 @@
#include "sysdeps/network.h"
#include "sysdeps/stat.h"
+#define _Nonnull
+#define _Nullable
+
#ifdef _WIN32
// Clang-only nullability specifiers
-#define _Nonnull
-#define _Nullable
#include <ctype.h>
#include <direct.h>

View File

@@ -0,0 +1,14 @@
Description: Fix the weird error by GCC7 that fails to match the correct parent method.
Author: Kai-Chung Yan
Forwarded: not-needed
--- a/system/core/libutils/include/utils/Vector.h
+++ b/system/core/libutils/include/utils/Vector.h
@@ -256,7 +256,7 @@
template<class TYPE> inline
const Vector<TYPE>& Vector<TYPE>::operator = (const Vector<TYPE>& rhs) const {
- VectorImpl::operator = (static_cast<const VectorImpl&>(rhs));
+ VectorImpl::operator = (rhs);
return *this;
}

View File

@@ -0,0 +1,41 @@
Forwarded: not-needed
--- a/system/core/fs_mgr/liblp/reader.cpp
+++ b/system/core/fs_mgr/liblp/reader.cpp
@@ -22,6 +22,7 @@
#include <unistd.h>
#include <functional>
+#include <cstring>
#include <android-base/file.h>
#include <android-base/unique_fd.h>
--- a/system/core/fs_mgr/liblp/writer.cpp
+++ b/system/core/fs_mgr/liblp/writer.cpp
@@ -21,6 +21,7 @@
#include <unistd.h>
#include <string>
+#include <cstring>
#include <android-base/file.h>
#include <android-base/unique_fd.h>
--- a/system/core/liblog/logger_write.cpp
+++ b/system/core/liblog/logger_write.cpp
@@ -27,6 +27,7 @@
#include <android/set_abort_message.h>
#endif
+#include <mutex>
#include <shared_mutex>
#include <android-base/errno_restorer.h>
--- a/system/core/libziparchive/zip_archive_stream_entry.cc
+++ b/system/core/libziparchive/zip_archive_stream_entry.cc
@@ -23,6 +23,7 @@
#include <sys/types.h>
#include <unistd.h>
+#include <limits>
#include <memory>
#include <vector>

View File

@@ -0,0 +1,13 @@
Description: Off-by-one error in the dwarf_to_unw_regnum function in include/dwarf_i.h in
libunwind 1.1 allows local users to have unspecified impact via invalid dwarf opcodes.
--- a/external/libunwind/include/dwarf_i.h
+++ b/external/libunwind/include/dwarf_i.h
@@ -20,7 +20,7 @@
extern const uint8_t dwarf_to_unw_regnum_map[DWARF_REGNUM_MAP_LENGTH];
/* REG is evaluated multiple times; it better be side-effects free! */
# define dwarf_to_unw_regnum(reg) \
- (((reg) <= DWARF_REGNUM_MAP_LENGTH) ? dwarf_to_unw_regnum_map[reg] : 0)
+ (((reg) < DWARF_REGNUM_MAP_LENGTH) ? dwarf_to_unw_regnum_map[reg] : 0)
#endif
#ifdef UNW_LOCAL_ONLY

View File

@@ -0,0 +1,26 @@
Description: Replace the legacy __sync built-in functions with __atomic ones
libunwind uses the built-in __sync_* functions which are deprecated by GCC and
should be replaced by __atomic_* ones. See the official manuals [1].
.
The legacy __sync functions do not require to specify the memory order but
__atomic ones do, so we choose the strongest one: __ATOMIC_SEQ_CST.
.
We do this because __sync_fetch_and_add() is not supported on armel.
.
[1]: https://gcc.gnu.org/onlinedocs/gcc/_005f_005fsync-Builtins.html
Author: Kai-Chung Yan ()
Last-Update: 2016-10-04
Forwarded: not-needed
--- a/external/libunwind/include/libunwind_i.h
+++ b/external/libunwind/include/libunwind_i.h
@@ -155,8 +155,8 @@ cmpxchg_ptr (void *addr, void *old, void
u.vp = addr;
return __sync_bool_compare_and_swap(u.vlp, (long) old, (long) new);
}
-# define fetch_and_add1(_ptr) __sync_fetch_and_add(_ptr, 1)
-# define fetch_and_add(_ptr, value) __sync_fetch_and_add(_ptr, value)
+# define fetch_and_add1(_ptr) __atomic_fetch_add(_ptr, 1, __ATOMIC_SEQ_CST)
+# define fetch_and_add(_ptr, value) __atomic_fetch_add(_ptr, value, __ATOMIC_SEQ_CST)
# define HAVE_CMPXCHG
# define HAVE_FETCH_AND_ADD
#endif

View File

@@ -0,0 +1,24 @@
Author: Kai-Chung Yan <seamlikok@gmail.com>
Last-Update: 2016-08-24
Description: Manual definition of struct user_pt_regs
On ARM64, libunwind uses struct user_pt_regs which is not defined in
anywhere, which causes FTBFS.
Forwarded: not-needed
--- a/external/libunwind/src/ptrace/_UPT_access_reg.c
+++ b/external/libunwind/src/ptrace/_UPT_access_reg.c
@@ -26,6 +26,15 @@ WITH THE SOFTWARE OR THE USE OR OTHER DE
#include "_UPT_internal.h"
+#if defined(__aarch64__)
+ struct user_pt_regs {
+ __u64 regs[31];
+ __u64 sp;
+ __u64 pc;
+ __u64 pstate;
+ };
+#endif
+
#if UNW_TARGET_IA64
# include <elf.h>
# ifdef HAVE_ASM_PTRACE_OFFSETS_H

View File

@@ -0,0 +1,17 @@
Description: remove clang-ism
Forwarded: not-needed
--- a/system/core/base/include/android-base/logging.h
+++ b/system/core/base/include/android-base/logging.h
@@ -451,10 +451,7 @@
// -Wno-user-defined-warnings to CPPFLAGS.
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wgcc-compat"
-#define OSTREAM_STRING_POINTER_USAGE_WARNING \
- __attribute__((diagnose_if(true, "Unexpected logging of string pointer", "warning")))
-inline OSTREAM_STRING_POINTER_USAGE_WARNING
-std::ostream& operator<<(std::ostream& stream, const std::string* string_pointer) {
+inline std::ostream& operator<<(std::ostream& stream, const std::string* string_pointer) {
return stream << static_cast<const void*>(string_pointer);
}
#pragma clang diagnostic pop

View File

@@ -0,0 +1,24 @@
Description: non-x86 arches do not have PAGE_SIZE
Forwarded: not-needed
--- a/system/core/base/cmsg.cpp
+++ b/system/core/base/cmsg.cpp
@@ -33,7 +33,8 @@
const std::vector<int>& fds) {
size_t cmsg_space = CMSG_SPACE(sizeof(int) * fds.size());
size_t cmsg_len = CMSG_LEN(sizeof(int) * fds.size());
- if (cmsg_space >= PAGE_SIZE) {
+ size_t pagesize = static_cast<size_t>(sysconf(_SC_PAGE_SIZE));
+ if (cmsg_space >= pagesize) {
errno = ENOMEM;
return -1;
}
@@ -75,7 +76,8 @@
fds->clear();
size_t cmsg_space = CMSG_SPACE(sizeof(int) * max_fds);
- if (cmsg_space >= PAGE_SIZE) {
+ size_t pagesize = static_cast<size_t>(sysconf(_SC_PAGE_SIZE));
+ if (cmsg_space >= pagesize) {
errno = ENOMEM;
return -1;
}

View File

@@ -0,0 +1,24 @@
Description: get libcutils building
Forwarded: not-needed
--- a/system/core/libcutils/include/cutils/threads.h
+++ b/system/core/libcutils/include/cutils/threads.h
@@ -33,7 +33,7 @@
// Deprecated: use android::base::GetThreadId instead, which doesn't truncate on Mac/Windows.
//
-extern pid_t gettid();
+extern pid_t gettid(void) __THROW;
//
// Deprecated: use `_Thread_local` in C or `thread_local` in C++.
--- a/system/core/libcutils/threads.cpp
+++ b/system/core/libcutils/threads.cpp
@@ -33,7 +33,7 @@
// No definition needed for Android because we'll just pick up bionic's copy.
#ifndef __ANDROID__
-pid_t gettid() {
+pid_t gettid(void) __THROW {
#if defined(__APPLE__)
uint64_t tid;
pthread_threadid_np(NULL, &tid);

View File

@@ -0,0 +1,22 @@
Description: Add missing 'std::' scope identifiers.
Forwarded: not-needed
--- a/system/core/libunwindstack/include/unwindstack/DwarfMemory.h
+++ b/system/core/libunwindstack/include/unwindstack/DwarfMemory.h
@@ -29,7 +29,7 @@
DwarfMemory(Memory* memory) : memory_(memory) {}
virtual ~DwarfMemory() = default;
- bool ReadBytes(void* dst, size_t num_bytes);
+ bool ReadBytes(void* dst, std::size_t num_bytes);
template <typename SignedType>
bool ReadSigned(uint64_t* value);
@@ -39,7 +39,7 @@
bool ReadSLEB128(int64_t* value);
template <typename AddressType>
- size_t GetEncodedSize(uint8_t encoding);
+ std::size_t GetEncodedSize(uint8_t encoding);
bool AdjustEncodedValue(uint8_t encoding, uint64_t* value);

View File

@@ -0,0 +1,44 @@
Description: just hard code rather than deal with circular deps
Forwarded: not-needed
--- a/system/core/adb/adb.cpp
+++ b/system/core/adb/adb.cpp
@@ -44,8 +44,6 @@
#include <android-base/parsenetaddress.h>
#include <android-base/stringprintf.h>
#include <android-base/strings.h>
-#include <build/version.h>
-#include <platform_tools_version.h>
#include "adb_auth.h"
#include "adb_io.h"
@@ -69,7 +67,7 @@
"Version %s-%s\n"
"Installed as %s\n",
ADB_VERSION_MAJOR, ADB_VERSION_MINOR, ADB_SERVER_VERSION,
- PLATFORM_TOOLS_VERSION, android::build::GetBuildNumber().c_str(),
+ PLATFORM_TOOLS_VERSION, "debian",
android::base::GetExecutablePath().c_str());
}
--- a/system/core/fastboot/fastboot.cpp
+++ b/system/core/fastboot/fastboot.cpp
@@ -59,10 +59,8 @@
#include <android-base/stringprintf.h>
#include <android-base/strings.h>
#include <android-base/unique_fd.h>
-#include <build/version.h>
#include <libavb/libavb.h>
#include <liblp/liblp.h>
-#include <platform_tools_version.h>
#include <sparse/sparse.h>
#include <ziparchive/zip_archive.h>
@@ -1680,7 +1678,7 @@
setvbuf(stdout, nullptr, _IONBF, 0);
setvbuf(stderr, nullptr, _IONBF, 0);
} else if (name == "version") {
- fprintf(stdout, "fastboot version %s-%s\n", PLATFORM_TOOLS_VERSION, android::build::GetBuildNumber().c_str());
+ fprintf(stdout, "fastboot version %s-%s\n", PLATFORM_TOOLS_VERSION, "debian");
fprintf(stdout, "Installed as %s\n", android::base::GetExecutablePath().c_str());
return 0;
#if !defined(_WIN32)

View File

@@ -0,0 +1,16 @@
Description: libusb.h comes from different location
Author: Umang Parmar <umangjparmar@gmail.com>
Forwarded: not-needed
Last-Update: 2018-05-26
--- a/system/core/adb/client/usb_libusb.cpp
+++ b/system/core/adb/client/usb_libusb.cpp
@@ -30,7 +30,7 @@
#include <thread>
#include <unordered_map>
-#include <libusb/libusb.h>
+#include <libusb-1.0/libusb.h>
#include <android-base/file.h>
#include <android-base/logging.h>

View File

@@ -0,0 +1,18 @@
Description: Update log file directory.
Author: Umang Parmar <umangjparmar@gmail.com>
Last Updated: 2018-05-17
--- a/system/core/adb/adb_utils.cpp
+++ b/system/core/adb/adb_utils.cpp
@@ -339,6 +339,11 @@
return temp_path_utf8 + log_name;
#else
+ std::string log_dir = android::base::StringPrintf("/run/user/%u/adb.log", getuid());
+ struct stat st = {0};
+ if (stat(log_dir.c_str(), &st) == 0) {
+ return log_dir;
+ }
const char* tmp_dir = getenv("TMPDIR");
if (tmp_dir == nullptr) tmp_dir = "/tmp";
return android::base::StringPrintf("%s/adb.%u.log", tmp_dir, getuid());

View File

@@ -0,0 +1,62 @@
Description: Port simg_dump to Python 3.
Author: Antonio Russo <antonio.e.russo@gmail.com>
Forwarded: not-needed
Last-Update: 2019-01-05
Origin: https://bugs.debian.org/945646
---
Index: android-platform-tools/system/core/libsparse/simg_dump.py
===================================================================
--- android-platform-tools.orig/system/core/libsparse/simg_dump.py
+++ android-platform-tools/system/core/libsparse/simg_dump.py
@@ -1,4 +1,4 @@
-#! /usr/bin/env python
+#! /usr/bin/env python3
# Copyright (C) 2012 The Android Open Source Project
#
@@ -14,7 +14,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-from __future__ import print_function
+
import csv
import getopt
import hashlib
@@ -47,7 +47,7 @@ def main():
opts, args = getopt.getopt(sys.argv[1:],
"vsc:",
["verbose", "showhash", "csvfile"])
- except getopt.GetoptError, e:
+ except getopt.GetoptError as e:
print(e)
usage(me)
for o, a in opts:
@@ -66,7 +66,7 @@ def main():
usage(me)
if csvfilename:
- csvfile = open(csvfilename, "wb")
+ csvfile = open(csvfilename, "w", newline='')
csvwriter = csv.writer(csvfile)
output = verbose or csvfilename or showhash
@@ -121,7 +121,7 @@ def main():
"output offset", "output blocks", "type", "hash"])
offset = 0
- for i in xrange(1, total_chunks + 1):
+ for i in range(1, total_chunks + 1):
header_bin = FH.read(12)
header = struct.unpack("<2H2I", header_bin)
chunk_type = header[0]
@@ -160,7 +160,7 @@ def main():
if showhash:
h = hashlib.sha1()
data = fill_bin * (blk_sz / 4);
- for block in xrange(chunk_sz):
+ for block in range(chunk_sz):
h.update(data)
curhash = h.hexdigest()
elif chunk_type == 0xCAC3:

View File

@@ -0,0 +1,64 @@
Description: Fix incompatibility between <stdatomic.h> and <atomic>
This 2 headers combined will cause errors for both GCC and Clang. This patch
makes sure only one of them is present at any time.
Bug: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60932
Bug: https://reviews.llvm.org/D45470
--- a/system/core/libcutils/include/cutils/trace.h
+++ b/system/core/libcutils/include/cutils/trace.h
@@ -18,7 +18,14 @@
#define _LIBS_CUTILS_TRACE_H
#include <inttypes.h>
+#ifdef __cplusplus
+#include <atomic>
+using std::atomic_bool;
+using std::atomic_load_explicit;
+using std::memory_order_acquire;
+#else
#include <stdatomic.h>
+#endif
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
--- a/system/core/libcutils/include/cutils/atomic.h
+++ b/system/core/libcutils/include/cutils/atomic.h
@@ -19,7 +19,23 @@
#include <stdint.h>
#include <sys/types.h>
+#ifdef __cplusplus
+#include <atomic>
+using std::atomic_compare_exchange_strong_explicit;
+using std::atomic_fetch_add_explicit;
+using std::atomic_fetch_or_explicit;
+using std::atomic_fetch_sub_explicit;
+using std::atomic_int_least32_t;
+using std::atomic_load_explicit;
+using std::atomic_store_explicit;
+using std::atomic_thread_fence;
+using std::memory_order::memory_order_acquire;
+using std::memory_order::memory_order_relaxed;
+using std::memory_order::memory_order_release;
+using std::memory_order::memory_order_seq_cst;
+#else
#include <stdatomic.h>
+#endif
#ifndef ANDROID_ATOMIC_INLINE
#define ANDROID_ATOMIC_INLINE static inline
--- a/system/core/liblog/logger.h
+++ b/system/core/liblog/logger.h
@@ -16,7 +16,13 @@
#pragma once
+#ifdef __cplusplus
+#include <atomic>
+using std::atomic_int;
+using std::atomic_uintptr_t;
+#else
#include <stdatomic.h>
+#endif
#include <sys/cdefs.h>
#include <log/log.h>

View File

@@ -0,0 +1,93 @@
Description: Defer packaging fastdeploy with adb for 29.x.x tags.
Forwarded: not-needed
--- a/system/core/adb/client/commandline.cpp
+++ b/system/core/adb/client/commandline.cpp
@@ -59,7 +59,6 @@
#include "bugreport.h"
#include "client/file_sync_client.h"
#include "commandline.h"
-#include "fastdeploy.h"
#include "services.h"
#include "shell_protocol.h"
#include "sysdeps/chrono.h"
--- a/system/core/adb/client/adb_install.cpp
+++ b/system/core/adb/client/adb_install.cpp
@@ -35,7 +35,6 @@
#include "adb_utils.h"
#include "client/file_sync_client.h"
#include "commandline.h"
-#include "fastdeploy.h"
static constexpr int kFastDeployMinApi = 24;
@@ -167,14 +166,6 @@
}
if (use_fastdeploy) {
- auto metadata = extract_metadata(file);
- if (metadata.has_value()) {
- // pass all but 1st (command) and last (apk path) parameters through to pm for
- // session creation
- std::vector<const char*> pm_args{argv + 1, argv + argc - 1};
- auto patchFd = install_patch(pm_args.size(), pm_args.data());
- return stream_patch(file, std::move(metadata.value()), std::move(patchFd));
- }
}
struct stat sb;
@@ -267,16 +258,6 @@
argv[last_apk] = apk_dest.c_str(); /* destination name, not source location */
if (use_fastdeploy) {
- auto metadata = extract_metadata(apk_file[0]);
- if (metadata.has_value()) {
- auto patchFd = apply_patch_on_device(apk_dest.c_str());
- int status = stream_patch(apk_file[0], std::move(metadata.value()), std::move(patchFd));
-
- result = pm_command(argc, argv);
- delete_device_file(apk_dest);
-
- return status;
- }
}
if (do_sync_push(apk_file, apk_dest.c_str(), false)) {
@@ -292,7 +273,6 @@
InstallMode installMode = INSTALL_DEFAULT;
bool use_fastdeploy = false;
bool is_reinstall = false;
- FastDeploy_AgentUpdateStrategy agent_update_strategy = FastDeploy_AgentUpdateDifferentVersion;
for (int i = 1; i < argc; i++) {
if (!strcmp(argv[i], "--streaming")) {
@@ -313,13 +293,10 @@
use_fastdeploy = false;
} else if (!strcmp(argv[i], "--force-agent")) {
processedArgIndicies.push_back(i);
- agent_update_strategy = FastDeploy_AgentUpdateAlways;
} else if (!strcmp(argv[i], "--date-check-agent")) {
processedArgIndicies.push_back(i);
- agent_update_strategy = FastDeploy_AgentUpdateNewerTimeStamp;
} else if (!strcmp(argv[i], "--version-check-agent")) {
processedArgIndicies.push_back(i);
- agent_update_strategy = FastDeploy_AgentUpdateDifferentVersion;
}
}
@@ -331,13 +308,11 @@
error_exit("Attempting to use streaming install on unsupported device");
}
- if (use_fastdeploy && get_device_api_level() < kFastDeployMinApi) {
- printf("Fast Deploy is only compatible with devices of API version %d or higher, "
- "ignoring.\n",
- kFastDeployMinApi);
+ if (use_fastdeploy) {
+ printf("Fast Deploy is unavailable in this build of adb, "
+ "ignoring.\n");
use_fastdeploy = false;
}
- fastdeploy_set_agent_update_strategy(agent_update_strategy);
std::vector<const char*> passthrough_argv;
for (int i = 0; i < argc; i++) {

View File

@@ -0,0 +1,651 @@
From: Guo Ren <guoren@linux.alibaba.com>
Date: Wed, 29 Jun 2022 16:46:46 +0800
Subject: Add riscv64 support
This patch contains the dwarf unwind support for 64bit risc-v.
* DwarfCfa.cpp (cfa_def_cfa_register): setup register if CFA_REG is
not setup for riscv64
* Elf.cpp (GetRelPc): convert offset to virtual address for riscv64.
* ElfInterface.cpp (GetVirtAddrFromOffset): New for riscv64.
* RegsRiscv64.cpp (StepIfSignalHandler): Fix signal frame check.
libunwindstack/include/unwindstack/
* ElfInterface.h (GetVirtAddrFromOffset): New for riscv64.
libunwindstack/tests/
* DwarfCfaTest.cpp (cfa_def_cfa_register): ok for riscv64.
* RegsStepIfSignalHandlerTest.cpp (riscv64_step_if_signal_handler): Fix
testcase for riscv64
Test: Builds.
Test: All unit tests pass.
Signed-off-by: Guo Ren <guoren@linux.alibaba.com>
Signed-off-by: Lifang Xia <lifang_xia@linux.alibaba.com>
Signed-off-by: Mao Han <han_mao@linux.alibaba.com>
Change-Id: Ib21ddf23cc83f332af202df7bffcaceec16063e0
---
system/core/libunwindstack/Android.bp | 1 +
system/core/libunwindstack/Elf.cpp | 2 +
system/core/libunwindstack/Regs.cpp | 10 ++
system/core/libunwindstack/RegsRiscv64.cpp | 156 +++++++++++++++++++++
.../core/libunwindstack/include/unwindstack/Elf.h | 5 +
.../include/unwindstack/MachineRiscv64.h | 59 ++++++++
.../include/unwindstack/RegsGetLocal.h | 43 ++++++
.../include/unwindstack/RegsRiscv64.h | 59 ++++++++
.../include/unwindstack/UcontextRiscv64.h | 80 +++++++++++
.../include/unwindstack/UserRiscv64.h | 37 +++++
system/core/libunwindstack/tools/unwind.cpp | 3 +
.../core/libunwindstack/tools/unwind_symbols.cpp | 3 +
12 files changed, 458 insertions(+)
create mode 100644 system/core/libunwindstack/RegsRiscv64.cpp
create mode 100644 system/core/libunwindstack/include/unwindstack/MachineRiscv64.h
create mode 100644 system/core/libunwindstack/include/unwindstack/RegsRiscv64.h
create mode 100644 system/core/libunwindstack/include/unwindstack/UcontextRiscv64.h
create mode 100644 system/core/libunwindstack/include/unwindstack/UserRiscv64.h
diff --git a/system/core/libunwindstack/Android.bp b/system/core/libunwindstack/Android.bp
index 3695f72..f1f9c68 100644
--- a/system/core/libunwindstack/Android.bp
+++ b/system/core/libunwindstack/Android.bp
@@ -70,6 +70,7 @@ cc_library {
"RegsArm64.cpp",
"RegsX86.cpp",
"RegsX86_64.cpp",
+ "RegsRiscv64.cpp",
"RegsMips.cpp",
"RegsMips64.cpp",
"Unwinder.cpp",
diff --git a/system/core/libunwindstack/Elf.cpp b/system/core/libunwindstack/Elf.cpp
index f01b092..3c2088b 100644
--- a/system/core/libunwindstack/Elf.cpp
+++ b/system/core/libunwindstack/Elf.cpp
@@ -290,6 +290,8 @@ ElfInterface* Elf::CreateInterfaceFromMemory(Memory* memory) {
arch_ = ARCH_X86_64;
} else if (e_machine == EM_MIPS) {
arch_ = ARCH_MIPS64;
+ } else if (e_machine == EM_RISCV) {
+ arch_ = ARCH_RISCV64;
} else {
// Unsupported.
ALOGI("64 bit elf that is neither aarch64 nor x86_64 nor mips64: e_machine = %d\n",
diff --git a/system/core/libunwindstack/Regs.cpp b/system/core/libunwindstack/Regs.cpp
index c7dec52..447a554 100644
--- a/system/core/libunwindstack/Regs.cpp
+++ b/system/core/libunwindstack/Regs.cpp
@@ -27,12 +27,14 @@
#include <unwindstack/RegsArm64.h>
#include <unwindstack/RegsMips.h>
#include <unwindstack/RegsMips64.h>
+#include <unwindstack/RegsRiscv64.h>
#include <unwindstack/RegsX86.h>
#include <unwindstack/RegsX86_64.h>
#include <unwindstack/UserArm.h>
#include <unwindstack/UserArm64.h>
#include <unwindstack/UserMips.h>
#include <unwindstack/UserMips64.h>
+#include <unwindstack/UserRiscv64.h>
#include <unwindstack/UserX86.h>
#include <unwindstack/UserX86_64.h>
@@ -67,6 +69,8 @@ Regs* Regs::RemoteGet(pid_t pid) {
return RegsMips::Read(buffer.data());
case sizeof(mips64_user_regs):
return RegsMips64::Read(buffer.data());
+ case sizeof(riscv64_user_regs):
+ return RegsRiscv64::Read(buffer.data());
}
return nullptr;
}
@@ -85,6 +89,8 @@ Regs* Regs::CreateFromUcontext(ArchEnum arch, void* ucontext) {
return RegsMips::CreateFromUcontext(ucontext);
case ARCH_MIPS64:
return RegsMips64::CreateFromUcontext(ucontext);
+ case ARCH_RISCV64:
+ return RegsRiscv64::CreateFromUcontext(ucontext);
case ARCH_UNKNOWN:
default:
return nullptr;
@@ -104,6 +110,8 @@ ArchEnum Regs::CurrentArch() {
return ARCH_MIPS;
#elif defined(__mips__) && defined(__LP64__)
return ARCH_MIPS64;
+#elif defined(__riscv)
+ return ARCH_RISCV64;
#else
abort();
#endif
@@ -123,6 +131,8 @@ Regs* Regs::CreateFromLocal() {
regs = new RegsMips();
#elif defined(__mips__) && defined(__LP64__)
regs = new RegsMips64();
+#elif defined(__riscv)
+ regs = new RegsRiscv64();
#else
abort();
#endif
diff --git a/system/core/libunwindstack/RegsRiscv64.cpp b/system/core/libunwindstack/RegsRiscv64.cpp
new file mode 100644
index 0000000..887762a
--- /dev/null
+++ b/system/core/libunwindstack/RegsRiscv64.cpp
@@ -0,0 +1,156 @@
+/*
+ * Copyright (C) 2022 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdint.h>
+#include <string.h>
+
+#include <functional>
+
+#include <unwindstack/Elf.h>
+#include <unwindstack/MachineRiscv64.h>
+#include <unwindstack/MapInfo.h>
+#include <unwindstack/Memory.h>
+#include <unwindstack/RegsRiscv64.h>
+#include <unwindstack/UcontextRiscv64.h>
+#include <unwindstack/UserRiscv64.h>
+
+namespace unwindstack {
+
+RegsRiscv64::RegsRiscv64()
+ : RegsImpl<uint64_t>(RISCV64_REG_MAX, Location(LOCATION_REGISTER, RISCV64_REG_RA)) {}
+
+ArchEnum RegsRiscv64::Arch() {
+ return ARCH_RISCV64;
+}
+
+uint64_t RegsRiscv64::pc() {
+ return regs_[RISCV64_REG_PC];
+}
+
+uint64_t RegsRiscv64::sp() {
+ return regs_[RISCV64_REG_SP];
+}
+
+void RegsRiscv64::set_pc(uint64_t pc) {
+ regs_[RISCV64_REG_PC] = pc;
+}
+
+void RegsRiscv64::set_sp(uint64_t sp) {
+ regs_[RISCV64_REG_SP] = sp;
+}
+
+uint64_t RegsRiscv64::GetPcAdjustment(uint64_t rel_pc, Elf*) {
+ if (rel_pc < 8) {
+ return 0;
+ }
+ // For now, just assume no compact branches
+ return 8;
+}
+
+bool RegsRiscv64::SetPcFromReturnAddress(Memory*) {
+ uint64_t ra = regs_[RISCV64_REG_RA];
+ if (regs_[RISCV64_REG_PC] == ra) {
+ return false;
+ }
+
+ regs_[RISCV64_REG_PC] = ra;
+ return true;
+}
+
+void RegsRiscv64::IterateRegisters(std::function<void(const char*, uint64_t)> fn) {
+ fn("pc", regs_[RISCV64_REG_PC]);
+ fn("ra", regs_[RISCV64_REG_RA]);
+ fn("sp", regs_[RISCV64_REG_SP]);
+ fn("gp", regs_[RISCV64_REG_GP]);
+ fn("tp", regs_[RISCV64_REG_TP]);
+ fn("t0", regs_[RISCV64_REG_T0]);
+ fn("t1", regs_[RISCV64_REG_T1]);
+ fn("t2", regs_[RISCV64_REG_T2]);
+ fn("t3", regs_[RISCV64_REG_T3]);
+ fn("t4", regs_[RISCV64_REG_T4]);
+ fn("t5", regs_[RISCV64_REG_T5]);
+ fn("t6", regs_[RISCV64_REG_T6]);
+ fn("s0", regs_[RISCV64_REG_S0]);
+ fn("s1", regs_[RISCV64_REG_S1]);
+ fn("s2", regs_[RISCV64_REG_S2]);
+ fn("s3", regs_[RISCV64_REG_S3]);
+ fn("s4", regs_[RISCV64_REG_S4]);
+ fn("s5", regs_[RISCV64_REG_S5]);
+ fn("s6", regs_[RISCV64_REG_S6]);
+ fn("s7", regs_[RISCV64_REG_S7]);
+ fn("s8", regs_[RISCV64_REG_S8]);
+ fn("s9", regs_[RISCV64_REG_S9]);
+ fn("s10", regs_[RISCV64_REG_S10]);
+ fn("s11", regs_[RISCV64_REG_S11]);
+ fn("a0", regs_[RISCV64_REG_A0]);
+ fn("a1", regs_[RISCV64_REG_A1]);
+ fn("a2", regs_[RISCV64_REG_A2]);
+ fn("a3", regs_[RISCV64_REG_A3]);
+ fn("a4", regs_[RISCV64_REG_A4]);
+ fn("a5", regs_[RISCV64_REG_A5]);
+ fn("a6", regs_[RISCV64_REG_A6]);
+ fn("a7", regs_[RISCV64_REG_A7]);
+}
+
+Regs* RegsRiscv64::Read(void* remote_data) {
+ riscv64_user_regs* user = reinterpret_cast<riscv64_user_regs*>(remote_data);
+
+ RegsRiscv64* regs = new RegsRiscv64();
+ memcpy(regs->RawData(), &user->regs[0], RISCV64_REG_MAX * sizeof(uint64_t));
+ // uint64_t* reg_data = reinterpret_cast<uint64_t*>(regs->RawData());
+ return regs;
+}
+
+Regs* RegsRiscv64::CreateFromUcontext(void* ucontext) {
+ riscv64_ucontext_t* riscv64_ucontext = reinterpret_cast<riscv64_ucontext_t*>(ucontext);
+
+ RegsRiscv64* regs = new RegsRiscv64();
+ memcpy(regs->RawData(), &riscv64_ucontext->uc_mcontext.__gregs[0],
+ RISCV64_REG_MAX * sizeof(uint64_t));
+ return regs;
+}
+
+bool RegsRiscv64::StepIfSignalHandler(uint64_t elf_offset, Elf* elf, Memory* process_memory) {
+ uint64_t data;
+ Memory* elf_memory = elf->memory();
+ // Read from elf memory since it is usually more expensive to read from
+ // process memory.
+ if (!elf_memory->ReadFully(elf_offset, &data, sizeof(data))) {
+ return false;
+ }
+ // Look for the kernel sigreturn function.
+ // __kernel_rt_sigreturn:
+ // li a7, __NR_rt_sigreturn
+ // scall
+
+ const uint8_t li_scall[] = {0x93, 0x08, 0xb0, 0x08, 0x73, 0x00, 0x00, 0x00};
+ if (memcmp(&data, &li_scall, 8) != 0) {
+ return false;
+ }
+
+ // SP + sizeof(siginfo_t) + uc_mcontext offset + PC offset.
+ if (!process_memory->ReadFully(regs_[RISCV64_REG_SP] + 0x80 + 0xb0 + 0x00, regs_.data(),
+ sizeof(uint64_t) * (RISCV64_REG_MAX))) {
+ return false;
+ }
+ return true;
+}
+
+Regs* RegsRiscv64::Clone() {
+ return new RegsRiscv64(*this);
+}
+
+} // namespace unwindstack
diff --git a/system/core/libunwindstack/include/unwindstack/Elf.h b/system/core/libunwindstack/include/unwindstack/Elf.h
index 472ed92..88fa0ff 100644
--- a/system/core/libunwindstack/include/unwindstack/Elf.h
+++ b/system/core/libunwindstack/include/unwindstack/Elf.h
@@ -32,6 +32,10 @@
#define EM_AARCH64 183
#endif
+#if !defined(EM_RISCV)
+#define EM_RISCV 243
+#endif
+
namespace unwindstack {
// Forward declaration.
@@ -46,6 +50,7 @@ enum ArchEnum : uint8_t {
ARCH_X86_64,
ARCH_MIPS,
ARCH_MIPS64,
+ ARCH_RISCV64,
};
class Elf {
diff --git a/system/core/libunwindstack/include/unwindstack/MachineRiscv64.h b/system/core/libunwindstack/include/unwindstack/MachineRiscv64.h
new file mode 100644
index 0000000..397e680
--- /dev/null
+++ b/system/core/libunwindstack/include/unwindstack/MachineRiscv64.h
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2022 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#pragma once
+
+#include <stdint.h>
+
+namespace unwindstack {
+
+enum Riscv64Reg : uint16_t {
+ RISCV64_REG_PC,
+ RISCV64_REG_RA,
+ RISCV64_REG_SP,
+ RISCV64_REG_GP,
+ RISCV64_REG_TP,
+ RISCV64_REG_T0,
+ RISCV64_REG_T1,
+ RISCV64_REG_T2,
+ RISCV64_REG_S0,
+ RISCV64_REG_S1,
+ RISCV64_REG_A0,
+ RISCV64_REG_A1,
+ RISCV64_REG_A2,
+ RISCV64_REG_A3,
+ RISCV64_REG_A4,
+ RISCV64_REG_A5,
+ RISCV64_REG_A6,
+ RISCV64_REG_A7,
+ RISCV64_REG_S2,
+ RISCV64_REG_S3,
+ RISCV64_REG_S4,
+ RISCV64_REG_S5,
+ RISCV64_REG_S6,
+ RISCV64_REG_S7,
+ RISCV64_REG_S8,
+ RISCV64_REG_S9,
+ RISCV64_REG_S10,
+ RISCV64_REG_S11,
+ RISCV64_REG_T3,
+ RISCV64_REG_T4,
+ RISCV64_REG_T5,
+ RISCV64_REG_T6,
+ RISCV64_REG_MAX,
+};
+
+} // namespace unwindstack
diff --git a/system/core/libunwindstack/include/unwindstack/RegsGetLocal.h b/system/core/libunwindstack/include/unwindstack/RegsGetLocal.h
index f0b5e3a..698eba2 100644
--- a/system/core/libunwindstack/include/unwindstack/RegsGetLocal.h
+++ b/system/core/libunwindstack/include/unwindstack/RegsGetLocal.h
@@ -81,6 +81,49 @@ inline __attribute__((__always_inline__)) void AsmGetRegs(void* reg_data) {
: "x12", "x13", "memory");
}
+#elif defined(__riscv)
+
+inline __attribute__((__always_inline__)) void AsmGetRegs(void* reg_data) {
+ asm volatile(
+ "1:\n"
+ "sd ra, 8(%[base])\n"
+ "sd sp, 16(%[base])\n"
+ "sd gp, 24(%[base])\n"
+ "sd tp, 32(%[base])\n"
+ "sd t0, 40(%[base])\n"
+ "sd t1, 48(%[base])\n"
+ "sd t2, 56(%[base])\n"
+ "sd s0, 64(%[base])\n"
+ "sd s1, 72(%[base])\n"
+ "sd a0, 80(%[base])\n"
+ "sd a1, 88(%[base])\n"
+ "sd a2, 96(%[base])\n"
+ "sd a3, 104(%[base])\n"
+ "sd a4, 112(%[base])\n"
+ "sd a5, 120(%[base])\n"
+ "sd a6, 128(%[base])\n"
+ "sd a7, 136(%[base])\n"
+ "sd s2, 144(%[base])\n"
+ "sd s3, 152(%[base])\n"
+ "sd s4, 160(%[base])\n"
+ "sd s5, 168(%[base])\n"
+ "sd s6, 176(%[base])\n"
+ "sd s7, 184(%[base])\n"
+ "sd s8, 192(%[base])\n"
+ "sd s9, 200(%[base])\n"
+ "sd s10, 208(%[base])\n"
+ "sd s11, 216(%[base])\n"
+ "sd t3, 224(%[base])\n"
+ "sd t4, 232(%[base])\n"
+ "sd t5, 240(%[base])\n"
+ "sd t6, 248(%[base])\n"
+ "la t1, 1b\n"
+ "sd t1, 0(%[base])\n"
+ : [base] "+r"(reg_data)
+ :
+ : "t1", "memory");
+}
+
#elif defined(__i386__) || defined(__x86_64__) || defined(__mips__)
extern "C" void AsmGetRegs(void* regs);
diff --git a/system/core/libunwindstack/include/unwindstack/RegsRiscv64.h b/system/core/libunwindstack/include/unwindstack/RegsRiscv64.h
new file mode 100644
index 0000000..eb09397
--- /dev/null
+++ b/system/core/libunwindstack/include/unwindstack/RegsRiscv64.h
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2022 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#pragma once
+
+#include <stdint.h>
+
+#include <functional>
+
+#include <unwindstack/Elf.h>
+#include <unwindstack/Regs.h>
+
+namespace unwindstack {
+
+// Forward declarations.
+class Memory;
+
+class RegsRiscv64 : public RegsImpl<uint64_t> {
+ public:
+ RegsRiscv64();
+ virtual ~RegsRiscv64() = default;
+
+ ArchEnum Arch() override final;
+
+ uint64_t GetPcAdjustment(uint64_t rel_pc, Elf* elf) override;
+
+ bool SetPcFromReturnAddress(Memory* process_memory) override;
+
+ bool StepIfSignalHandler(uint64_t elf_offset, Elf* elf, Memory* process_memory) override;
+
+ void IterateRegisters(std::function<void(const char*, uint64_t)>) override final;
+
+ uint64_t pc() override;
+ uint64_t sp() override;
+
+ void set_pc(uint64_t pc) override;
+ void set_sp(uint64_t sp) override;
+
+ Regs* Clone() override final;
+
+ static Regs* Read(void* data);
+
+ static Regs* CreateFromUcontext(void* ucontext);
+};
+
+} // namespace unwindstack
diff --git a/system/core/libunwindstack/include/unwindstack/UcontextRiscv64.h b/system/core/libunwindstack/include/unwindstack/UcontextRiscv64.h
new file mode 100644
index 0000000..c6c82b1
--- /dev/null
+++ b/system/core/libunwindstack/include/unwindstack/UcontextRiscv64.h
@@ -0,0 +1,80 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#pragma once
+
+#include <sys/cdefs.h>
+
+typedef uint64_t __riscv_mc_gp_state[32]; // unsigned long
+
+struct __riscv_mc_f_ext_state {
+ uint32_t __f[32];
+ uint32_t __fcsr;
+};
+
+struct __riscv_mc_d_ext_state {
+ uint64_t __f[32];
+ uint32_t __fcsr;
+};
+
+struct __riscv_mc_q_ext_state {
+ uint64_t __f[64] __attribute__((__aligned__(16)));
+ uint32_t __fcsr;
+ uint32_t __reserved[3];
+};
+
+union __riscv_mc_fp_state {
+ struct __riscv_mc_f_ext_state __f;
+ struct __riscv_mc_d_ext_state __d;
+ struct __riscv_mc_q_ext_state __q;
+};
+
+struct __riscv_stack_t {
+ uint64_t ss_sp;
+ int32_t ss_flags;
+ uint64_t ss_size;
+};
+
+struct riscv64_sigset_t {
+ uint64_t sig; // unsigned long
+};
+
+struct riscv64_mcontext_t {
+ __riscv_mc_gp_state __gregs;
+ union __riscv_mc_fp_state __fpregs;
+};
+
+struct riscv64_ucontext_t {
+ uint64_t uc_flags; // unsigned long
+ struct riscv64_ucontext_t* uc_link;
+ __riscv_stack_t uc_stack;
+ riscv64_sigset_t uc_sigmask;
+ /* The kernel adds extra padding here to allow sigset_t to grow. */
+ int8_t __padding[128 - sizeof(riscv64_sigset_t)]; // char
+ riscv64_mcontext_t uc_mcontext;
+};
diff --git a/system/core/libunwindstack/include/unwindstack/UserRiscv64.h b/system/core/libunwindstack/include/unwindstack/UserRiscv64.h
new file mode 100644
index 0000000..1e91228
--- /dev/null
+++ b/system/core/libunwindstack/include/unwindstack/UserRiscv64.h
@@ -0,0 +1,37 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#pragma once
+
+namespace unwindstack {
+
+struct riscv64_user_regs {
+ uint64_t regs[32];
+};
+
+} // namespace unwindstack
diff --git a/system/core/libunwindstack/tools/unwind.cpp b/system/core/libunwindstack/tools/unwind.cpp
index 1812e50..ae20891 100644
--- a/system/core/libunwindstack/tools/unwind.cpp
+++ b/system/core/libunwindstack/tools/unwind.cpp
@@ -83,6 +83,9 @@ void DoUnwind(pid_t pid) {
case unwindstack::ARCH_MIPS64:
printf("mips64");
break;
+ case unwindstack::ARCH_RISCV64:
+ printf("riscv64");
+ break;
default:
printf("unknown\n");
return;
diff --git a/system/core/libunwindstack/tools/unwind_symbols.cpp b/system/core/libunwindstack/tools/unwind_symbols.cpp
index 8df2284..976db56 100644
--- a/system/core/libunwindstack/tools/unwind_symbols.cpp
+++ b/system/core/libunwindstack/tools/unwind_symbols.cpp
@@ -77,6 +77,9 @@ int main(int argc, char** argv) {
case EM_AARCH64:
printf("ABI: arm64\n");
break;
+ case EM_RISCV:
+ printf("ABI: riscv64\n");
+ break;
case EM_386:
printf("ABI: x86\n");
break;

View File

@@ -0,0 +1,44 @@
Description: Added missing headers causing compile errors
Author: Umang Parmar <umangjparmar@gmail.com>
Forwarded: not-needed
--- a/system/core/adb/sysdeps/posix/network.cpp
+++ b/system/core/adb/sysdeps/posix/network.cpp
@@ -22,6 +22,7 @@
#include <sys/socket.h>
#include <string>
+#include <cstring>
#include <android-base/logging.h>
#include <android-base/stringprintf.h>
--- a/system/core/base/file.cpp
+++ b/system/core/base/file.cpp
@@ -26,6 +26,7 @@
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
+#include <cstring>
#include <memory>
#include <mutex>
--- a/system/core/libbacktrace/BacktraceMap.cpp
+++ b/system/core/libbacktrace/BacktraceMap.cpp
@@ -21,6 +21,7 @@
#include <stdint.h>
#include <sys/types.h>
#include <unistd.h>
+#include <algorithm>
#include <log/log.h>
--- a/system/core/libbacktrace/UnwindStackMap.cpp
+++ b/system/core/libbacktrace/UnwindStackMap.cpp
@@ -20,6 +20,7 @@
#include <string>
#include <vector>
+#include <algorithm>
#include <backtrace/BacktraceMap.h>
#include <unwindstack/Elf.h>

View File

@@ -0,0 +1,20 @@
Description: Bring Clang's _Nonnull keyword to GCC
Author: Kai-Chung Yan
Forwarded: not-needed
--- a/system/core/adb/sysdeps.h
+++ b/system/core/adb/sysdeps.h
@@ -40,11 +40,12 @@
#include "sysdeps/network.h"
#include "sysdeps/stat.h"
+#define _Nonnull
+#define _Nullable
+
#ifdef _WIN32
// Clang-only nullability specifiers
-#define _Nonnull
-#define _Nullable
#include <ctype.h>
#include <direct.h>

View File

@@ -0,0 +1,14 @@
Description: Fix the weird error by GCC7 that fails to match the correct parent method.
Author: Kai-Chung Yan
Forwarded: not-needed
--- a/system/core/libutils/include/utils/Vector.h
+++ b/system/core/libutils/include/utils/Vector.h
@@ -256,7 +256,7 @@
template<class TYPE> inline
const Vector<TYPE>& Vector<TYPE>::operator = (const Vector<TYPE>& rhs) const {
- VectorImpl::operator = (static_cast<const VectorImpl&>(rhs));
+ VectorImpl::operator = (rhs);
return *this;
}

View File

@@ -0,0 +1,41 @@
Forwarded: not-needed
--- a/system/core/fs_mgr/liblp/reader.cpp
+++ b/system/core/fs_mgr/liblp/reader.cpp
@@ -22,6 +22,7 @@
#include <unistd.h>
#include <functional>
+#include <cstring>
#include <android-base/file.h>
#include <android-base/unique_fd.h>
--- a/system/core/fs_mgr/liblp/writer.cpp
+++ b/system/core/fs_mgr/liblp/writer.cpp
@@ -21,6 +21,7 @@
#include <unistd.h>
#include <string>
+#include <cstring>
#include <android-base/file.h>
#include <android-base/unique_fd.h>
--- a/system/core/liblog/logger_write.cpp
+++ b/system/core/liblog/logger_write.cpp
@@ -27,6 +27,7 @@
#include <android/set_abort_message.h>
#endif
+#include <mutex>
#include <shared_mutex>
#include <android-base/errno_restorer.h>
--- a/system/core/libziparchive/zip_archive_stream_entry.cc
+++ b/system/core/libziparchive/zip_archive_stream_entry.cc
@@ -23,6 +23,7 @@
#include <sys/types.h>
#include <unistd.h>
+#include <limits>
#include <memory>
#include <vector>

View File

@@ -0,0 +1,17 @@
Description: remove clang-ism
Forwarded: not-needed
--- a/system/core/base/include/android-base/logging.h
+++ b/system/core/base/include/android-base/logging.h
@@ -451,10 +451,7 @@
// -Wno-user-defined-warnings to CPPFLAGS.
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wgcc-compat"
-#define OSTREAM_STRING_POINTER_USAGE_WARNING \
- __attribute__((diagnose_if(true, "Unexpected logging of string pointer", "warning")))
-inline OSTREAM_STRING_POINTER_USAGE_WARNING
-std::ostream& operator<<(std::ostream& stream, const std::string* string_pointer) {
+inline std::ostream& operator<<(std::ostream& stream, const std::string* string_pointer) {
return stream << static_cast<const void*>(string_pointer);
}
#pragma clang diagnostic pop

View File

@@ -0,0 +1,24 @@
Description: non-x86 arches do not have PAGE_SIZE
Forwarded: not-needed
--- a/system/core/base/cmsg.cpp
+++ b/system/core/base/cmsg.cpp
@@ -33,7 +33,8 @@
const std::vector<int>& fds) {
size_t cmsg_space = CMSG_SPACE(sizeof(int) * fds.size());
size_t cmsg_len = CMSG_LEN(sizeof(int) * fds.size());
- if (cmsg_space >= PAGE_SIZE) {
+ size_t pagesize = static_cast<size_t>(sysconf(_SC_PAGE_SIZE));
+ if (cmsg_space >= pagesize) {
errno = ENOMEM;
return -1;
}
@@ -75,7 +76,8 @@
fds->clear();
size_t cmsg_space = CMSG_SPACE(sizeof(int) * max_fds);
- if (cmsg_space >= PAGE_SIZE) {
+ size_t pagesize = static_cast<size_t>(sysconf(_SC_PAGE_SIZE));
+ if (cmsg_space >= pagesize) {
errno = ENOMEM;
return -1;
}

View File

@@ -0,0 +1,24 @@
Description: get libcutils building
Forwarded: not-needed
--- a/system/core/libcutils/include/cutils/threads.h
+++ b/system/core/libcutils/include/cutils/threads.h
@@ -33,7 +33,7 @@
// Deprecated: use android::base::GetThreadId instead, which doesn't truncate on Mac/Windows.
//
-extern pid_t gettid();
+extern pid_t gettid(void) __THROW;
//
// Deprecated: use `_Thread_local` in C or `thread_local` in C++.
--- a/system/core/libcutils/threads.cpp
+++ b/system/core/libcutils/threads.cpp
@@ -33,7 +33,7 @@
// No definition needed for Android because we'll just pick up bionic's copy.
#ifndef __ANDROID__
-pid_t gettid() {
+pid_t gettid(void) __THROW {
#if defined(__APPLE__)
uint64_t tid;
pthread_threadid_np(NULL, &tid);

View File

@@ -0,0 +1,22 @@
Description: Add missing 'std::' scope identifiers.
Forwarded: not-needed
--- a/system/core/libunwindstack/include/unwindstack/DwarfMemory.h
+++ b/system/core/libunwindstack/include/unwindstack/DwarfMemory.h
@@ -29,7 +29,7 @@
DwarfMemory(Memory* memory) : memory_(memory) {}
virtual ~DwarfMemory() = default;
- bool ReadBytes(void* dst, size_t num_bytes);
+ bool ReadBytes(void* dst, std::size_t num_bytes);
template <typename SignedType>
bool ReadSigned(uint64_t* value);
@@ -39,7 +39,7 @@
bool ReadSLEB128(int64_t* value);
template <typename AddressType>
- size_t GetEncodedSize(uint8_t encoding);
+ std::size_t GetEncodedSize(uint8_t encoding);
bool AdjustEncodedValue(uint8_t encoding, uint64_t* value);

View File

@@ -0,0 +1,44 @@
Description: just hard code rather than deal with circular deps
Forwarded: not-needed
--- a/system/core/adb/adb.cpp
+++ b/system/core/adb/adb.cpp
@@ -44,8 +44,6 @@
#include <android-base/parsenetaddress.h>
#include <android-base/stringprintf.h>
#include <android-base/strings.h>
-#include <build/version.h>
-#include <platform_tools_version.h>
#include "adb_auth.h"
#include "adb_io.h"
@@ -69,7 +67,7 @@
"Version %s-%s\n"
"Installed as %s\n",
ADB_VERSION_MAJOR, ADB_VERSION_MINOR, ADB_SERVER_VERSION,
- PLATFORM_TOOLS_VERSION, android::build::GetBuildNumber().c_str(),
+ PLATFORM_TOOLS_VERSION, "debian",
android::base::GetExecutablePath().c_str());
}
--- a/system/core/fastboot/fastboot.cpp
+++ b/system/core/fastboot/fastboot.cpp
@@ -59,10 +59,8 @@
#include <android-base/stringprintf.h>
#include <android-base/strings.h>
#include <android-base/unique_fd.h>
-#include <build/version.h>
#include <libavb/libavb.h>
#include <liblp/liblp.h>
-#include <platform_tools_version.h>
#include <sparse/sparse.h>
#include <ziparchive/zip_archive.h>
@@ -1680,7 +1678,7 @@
setvbuf(stdout, nullptr, _IONBF, 0);
setvbuf(stderr, nullptr, _IONBF, 0);
} else if (name == "version") {
- fprintf(stdout, "fastboot version %s-%s\n", PLATFORM_TOOLS_VERSION, android::build::GetBuildNumber().c_str());
+ fprintf(stdout, "fastboot version %s-%s\n", PLATFORM_TOOLS_VERSION, "debian");
fprintf(stdout, "Installed as %s\n", android::base::GetExecutablePath().c_str());
return 0;
#if !defined(_WIN32)

View File

@@ -0,0 +1,16 @@
Description: libusb.h comes from different location
Author: Umang Parmar <umangjparmar@gmail.com>
Forwarded: not-needed
Last-Update: 2018-05-26
--- a/system/core/adb/client/usb_libusb.cpp
+++ b/system/core/adb/client/usb_libusb.cpp
@@ -30,7 +30,7 @@
#include <thread>
#include <unordered_map>
-#include <libusb/libusb.h>
+#include <libusb-1.0/libusb.h>
#include <android-base/file.h>
#include <android-base/logging.h>

View File

@@ -0,0 +1,18 @@
Description: Update log file directory.
Author: Umang Parmar <umangjparmar@gmail.com>
Last Updated: 2018-05-17
--- a/system/core/adb/adb_utils.cpp
+++ b/system/core/adb/adb_utils.cpp
@@ -339,6 +339,11 @@
return temp_path_utf8 + log_name;
#else
+ std::string log_dir = android::base::StringPrintf("/run/user/%u/adb.log", getuid());
+ struct stat st = {0};
+ if (stat(log_dir.c_str(), &st) == 0) {
+ return log_dir;
+ }
const char* tmp_dir = getenv("TMPDIR");
if (tmp_dir == nullptr) tmp_dir = "/tmp";
return android::base::StringPrintf("%s/adb.%u.log", tmp_dir, getuid());

View File

@@ -0,0 +1,62 @@
Description: Port simg_dump to Python 3.
Author: Antonio Russo <antonio.e.russo@gmail.com>
Forwarded: not-needed
Last-Update: 2019-01-05
Origin: https://bugs.debian.org/945646
---
Index: android-platform-tools/system/core/libsparse/simg_dump.py
===================================================================
--- android-platform-tools.orig/system/core/libsparse/simg_dump.py
+++ android-platform-tools/system/core/libsparse/simg_dump.py
@@ -1,4 +1,4 @@
-#! /usr/bin/env python
+#! /usr/bin/env python3
# Copyright (C) 2012 The Android Open Source Project
#
@@ -14,7 +14,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-from __future__ import print_function
+
import csv
import getopt
import hashlib
@@ -47,7 +47,7 @@ def main():
opts, args = getopt.getopt(sys.argv[1:],
"vsc:",
["verbose", "showhash", "csvfile"])
- except getopt.GetoptError, e:
+ except getopt.GetoptError as e:
print(e)
usage(me)
for o, a in opts:
@@ -66,7 +66,7 @@ def main():
usage(me)
if csvfilename:
- csvfile = open(csvfilename, "wb")
+ csvfile = open(csvfilename, "w", newline='')
csvwriter = csv.writer(csvfile)
output = verbose or csvfilename or showhash
@@ -121,7 +121,7 @@ def main():
"output offset", "output blocks", "type", "hash"])
offset = 0
- for i in xrange(1, total_chunks + 1):
+ for i in range(1, total_chunks + 1):
header_bin = FH.read(12)
header = struct.unpack("<2H2I", header_bin)
chunk_type = header[0]
@@ -160,7 +160,7 @@ def main():
if showhash:
h = hashlib.sha1()
data = fill_bin * (blk_sz / 4);
- for block in xrange(chunk_sz):
+ for block in range(chunk_sz):
h.update(data)
curhash = h.hexdigest()
elif chunk_type == 0xCAC3:

View File

@@ -0,0 +1,64 @@
Description: Fix incompatibility between <stdatomic.h> and <atomic>
This 2 headers combined will cause errors for both GCC and Clang. This patch
makes sure only one of them is present at any time.
Bug: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60932
Bug: https://reviews.llvm.org/D45470
--- a/system/core/libcutils/include/cutils/trace.h
+++ b/system/core/libcutils/include/cutils/trace.h
@@ -18,7 +18,14 @@
#define _LIBS_CUTILS_TRACE_H
#include <inttypes.h>
+#ifdef __cplusplus
+#include <atomic>
+using std::atomic_bool;
+using std::atomic_load_explicit;
+using std::memory_order_acquire;
+#else
#include <stdatomic.h>
+#endif
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
--- a/system/core/libcutils/include/cutils/atomic.h
+++ b/system/core/libcutils/include/cutils/atomic.h
@@ -19,7 +19,23 @@
#include <stdint.h>
#include <sys/types.h>
+#ifdef __cplusplus
+#include <atomic>
+using std::atomic_compare_exchange_strong_explicit;
+using std::atomic_fetch_add_explicit;
+using std::atomic_fetch_or_explicit;
+using std::atomic_fetch_sub_explicit;
+using std::atomic_int_least32_t;
+using std::atomic_load_explicit;
+using std::atomic_store_explicit;
+using std::atomic_thread_fence;
+using std::memory_order::memory_order_acquire;
+using std::memory_order::memory_order_relaxed;
+using std::memory_order::memory_order_release;
+using std::memory_order::memory_order_seq_cst;
+#else
#include <stdatomic.h>
+#endif
#ifndef ANDROID_ATOMIC_INLINE
#define ANDROID_ATOMIC_INLINE static inline
--- a/system/core/liblog/logger.h
+++ b/system/core/liblog/logger.h
@@ -16,7 +16,13 @@
#pragma once
+#ifdef __cplusplus
+#include <atomic>
+using std::atomic_int;
+using std::atomic_uintptr_t;
+#else
#include <stdatomic.h>
+#endif
#include <sys/cdefs.h>
#include <log/log.h>

View File

@@ -0,0 +1,93 @@
Description: Defer packaging fastdeploy with adb for 29.x.x tags.
Forwarded: not-needed
--- a/system/core/adb/client/commandline.cpp
+++ b/system/core/adb/client/commandline.cpp
@@ -59,7 +59,6 @@
#include "bugreport.h"
#include "client/file_sync_client.h"
#include "commandline.h"
-#include "fastdeploy.h"
#include "services.h"
#include "shell_protocol.h"
#include "sysdeps/chrono.h"
--- a/system/core/adb/client/adb_install.cpp
+++ b/system/core/adb/client/adb_install.cpp
@@ -35,7 +35,6 @@
#include "adb_utils.h"
#include "client/file_sync_client.h"
#include "commandline.h"
-#include "fastdeploy.h"
static constexpr int kFastDeployMinApi = 24;
@@ -167,14 +166,6 @@
}
if (use_fastdeploy) {
- auto metadata = extract_metadata(file);
- if (metadata.has_value()) {
- // pass all but 1st (command) and last (apk path) parameters through to pm for
- // session creation
- std::vector<const char*> pm_args{argv + 1, argv + argc - 1};
- auto patchFd = install_patch(pm_args.size(), pm_args.data());
- return stream_patch(file, std::move(metadata.value()), std::move(patchFd));
- }
}
struct stat sb;
@@ -267,16 +258,6 @@
argv[last_apk] = apk_dest.c_str(); /* destination name, not source location */
if (use_fastdeploy) {
- auto metadata = extract_metadata(apk_file[0]);
- if (metadata.has_value()) {
- auto patchFd = apply_patch_on_device(apk_dest.c_str());
- int status = stream_patch(apk_file[0], std::move(metadata.value()), std::move(patchFd));
-
- result = pm_command(argc, argv);
- delete_device_file(apk_dest);
-
- return status;
- }
}
if (do_sync_push(apk_file, apk_dest.c_str(), false)) {
@@ -292,7 +273,6 @@
InstallMode installMode = INSTALL_DEFAULT;
bool use_fastdeploy = false;
bool is_reinstall = false;
- FastDeploy_AgentUpdateStrategy agent_update_strategy = FastDeploy_AgentUpdateDifferentVersion;
for (int i = 1; i < argc; i++) {
if (!strcmp(argv[i], "--streaming")) {
@@ -313,13 +293,10 @@
use_fastdeploy = false;
} else if (!strcmp(argv[i], "--force-agent")) {
processedArgIndicies.push_back(i);
- agent_update_strategy = FastDeploy_AgentUpdateAlways;
} else if (!strcmp(argv[i], "--date-check-agent")) {
processedArgIndicies.push_back(i);
- agent_update_strategy = FastDeploy_AgentUpdateNewerTimeStamp;
} else if (!strcmp(argv[i], "--version-check-agent")) {
processedArgIndicies.push_back(i);
- agent_update_strategy = FastDeploy_AgentUpdateDifferentVersion;
}
}
@@ -331,13 +308,11 @@
error_exit("Attempting to use streaming install on unsupported device");
}
- if (use_fastdeploy && get_device_api_level() < kFastDeployMinApi) {
- printf("Fast Deploy is only compatible with devices of API version %d or higher, "
- "ignoring.\n",
- kFastDeployMinApi);
+ if (use_fastdeploy) {
+ printf("Fast Deploy is unavailable in this build of adb, "
+ "ignoring.\n");
use_fastdeploy = false;
}
- fastdeploy_set_agent_update_strategy(agent_update_strategy);
std::vector<const char*> passthrough_argv;
for (int i = 0; i < argc; i++) {

View File

@@ -0,0 +1,16 @@
Description: Turn #error into exceptions
So the library can be built on non-Linux platforms too, although can't
guarauntee its functionality regarding that piece of code.
Forwarded: not-needed
--- a/system/core/base/file.cpp
+++ b/system/core/base/file.cpp
@@ -422,7 +422,8 @@
path[PATH_MAX - 1] = 0;
return path;
#else
-#error unknown OS
+#include <stdexcept>
+ throw std::runtime_error(std::string("Unknown OS!"));
#endif
}

View File

@@ -0,0 +1,16 @@
Description: Turn #error into exceptions
So the library can be built on non-Linux platforms too, although can't
guarauntee its functionality regarding that piece of code.
Forwarded: not-needed
--- a/system/core/base/file.cpp
+++ b/system/core/base/file.cpp
@@ -422,7 +422,8 @@
path[PATH_MAX - 1] = 0;
return path;
#else
-#error unknown OS
+#include <stdexcept>
+ throw std::runtime_error(std::string("Unknown OS!"));
#endif
}

View File

@@ -0,0 +1,2 @@
#!/bin/sh
mount -o remount,rw /

View File

@@ -0,0 +1,194 @@
DESCRIPTION = "Various utilities from Android"
SECTION = "console/utils"
LICENSE = "Apache-2.0 & GPL-2.0-only & BSD-2-Clause & BSD-3-Clause"
LIC_FILES_CHKSUM = " \
file://${COMMON_LICENSE_DIR}/Apache-2.0;md5=89aea4e17d99a7cacdbeed46a0096b10 \
file://${COMMON_LICENSE_DIR}/GPL-2.0-only;md5=801f80980d171dd6425610833a22dbe6 \
file://${COMMON_LICENSE_DIR}/BSD-2-Clause;md5=cb641bc04cda31daea161b1bc15da69f \
file://${COMMON_LICENSE_DIR}/BSD-3-Clause;md5=550794465ba0ec5312d6919e203a55f9 \
"
DEPENDS = "libbsd libpcre zlib libcap libusb squashfs-tools p7zip libselinux googletest"
SRCREV_core = "abfd66fafcbb691d7860df059f1df1c9b1ef29da"
SRC_URI = " \
git://salsa.debian.org/android-tools-team/android-platform-tools;name=core;protocol=https;nobranch=1 \
"
# Patches copied from android-platform-tools/debian/patches
# and applied in the order defined by the file debian/patches/series
SRC_URI += " \
file://debian/external/libunwind/user_pt_regs.patch \
file://debian/external/libunwind/legacy_built-in_sync_functions.patch \
file://debian/external/libunwind/20150704-CVE-2015-3239_dwarf_i.h.patch \
\
file://debian/system/core/move-log-file-to-proper-dir.patch \
file://debian/system/core/Added-missing-headers.patch \
file://debian/system/core/libusb-header-path.patch \
file://debian/system/core/stdatomic.patch \
file://debian/system/core/Nonnull.patch \
file://debian/system/core/Vector-cast.patch \
file://debian/system/core/throw-exception-on-unknown-os.patch \
file://debian/system/core/simg_dump-python3.patch \
file://debian/system/core/fix-attribute-issue-with-gcc.patch \
file://debian/system/core/fix-gettid-exception-declaration.patch \
file://debian/system/core/fix-build-on-non-x86.patch \
file://debian/system/core/add-missing-headers.patch \
file://debian/system/core/hard-code-build-number.patch \
file://debian/system/core/stub-out-fastdeploy.patch \
file://debian/system/core/fix-standard-namespace-errors.patch \
file://debian/system/core/Add-riscv64-support.patch \
\
"
# patches which don't come from debian
SRC_URI += " \
file://rules_yocto.mk;subdir=git \
file://android-tools-adbd.service \
file://adbd.mk;subdir=git/debian/system/core \
file://remount \
file://0001-Fixes-for-yocto-build.patch \
file://0002-android-tools-modifications-to-make-it-build-in-yoct.patch \
file://0003-Update-usage-of-usbdevfs_urb-to-match-new-kernel-UAP.patch \
file://0004-adb-Fix-build-on-big-endian-systems.patch \
file://0005-adb-Allow-adbd-to-be-run-as-root.patch \
"
S = "${WORKDIR}/git"
B = "${WORKDIR}/${BPN}"
# http://errors.yoctoproject.org/Errors/Details/1debian881/
ARM_INSTRUCTION_SET:armv4 = "arm"
ARM_INSTRUCTION_SET:armv5 = "arm"
COMPATIBLE_HOST:powerpc = "(null)"
COMPATIBLE_HOST:powerpc64 = "(null)"
COMPATIBLE_HOST:powerpc64le = "(null)"
inherit systemd
SYSTEMD_SERVICE:${PN}-adbd = "android-tools-adbd.service"
# Find libbsd headers during native builds
CC:append:class-native = " -I${STAGING_INCDIR}"
CC:append:class-nativesdk = " -I${STAGING_INCDIR}"
PREREQUISITE_core = "liblog libbase libsparse liblog libcutils"
TOOLS_TO_BUILD = "libcrypto_utils libadb libziparchive fastboot adb img2simg simg2img libbacktrace"
TOOLS_TO_BUILD:append:class-target = " adbd"
do_compile() {
case "${HOST_ARCH}" in
arm)
export android_arch=linux-arm
cpu=arm
deb_host_arch=arm
;;
aarch64)
export android_arch=linux-arm64
cpu=arm64
deb_host_arch=arm64
;;
riscv64)
export android_arch=linux-riscv64
;;
mips|mipsel)
export android_arch=linux-mips
cpu=mips
deb_host_arch=mips
;;
mips64|mips64el)
export android_arch=linux-mips64
cpu=mips64
deb_host_arch=mips64
;;
powerpc|powerpc64)
export android_arch=linux-ppc
;;
i586|i686|x86_64)
export android_arch=linux-x86
cpu=x86_64
deb_host_arch=amd64
;;
esac
export SRCDIR=${S}
oe_runmake -f ${S}/debian/external/boringssl/libcrypto.mk -C ${S}
oe_runmake -f ${S}/debian/external/libunwind/libunwind.mk -C ${S} CPU=${cpu}
for tool in ${PREREQUISITE_core}; do
oe_runmake -f ${S}/debian/system/core/${tool}.mk -C ${S}
done
for i in `find ${S}/debian/system/extras/ -name "*.mk"`; do
oe_runmake -f $i -C ${S}
done
for tool in ${TOOLS_TO_BUILD}; do
if [ "$tool" = "libbacktrace" ]; then
oe_runmake -f ${S}/debian/system/core/${tool}.mk -C ${S} DEB_HOST_ARCH=${deb_host_arch}
else
oe_runmake -f ${S}/debian/system/core/${tool}.mk -C ${S}
fi
done
}
do_install() {
install -d ${D}${base_sbindir}
install -m 0755 ${S}/../remount -D ${D}${base_sbindir}/remount
for tool in img2simg simg2img fastboot adbd; do
if echo ${TOOLS_TO_BUILD} | grep -q "$tool" ; then
install -D -p -m0755 ${S}/debian/out/system/core/$tool ${D}${bindir}/$tool
fi
done
# grep adb also matches adbd, so handle adb separately from other tools
if echo ${TOOLS_TO_BUILD} | grep -q "adb " ; then
install -d ${D}${bindir}
install -m0755 ${S}/debian/out/system/core/adb ${D}${bindir}
fi
# Outside the if statement to avoid errors during do_package
install -D -p -m0644 ${WORKDIR}/android-tools-adbd.service \
${D}${systemd_unitdir}/system/android-tools-adbd.service
install -d ${D}${libdir}/android/
install -m0755 ${S}/debian/out/system/core/*.so.* ${D}${libdir}/android/
if echo ${TOOLS_TO_BUILD} | grep -q "mkbootimg" ; then
install -d ${D}${bindir}
install -m0755 ${B}/mkbootimg/mkbootimg ${D}${bindir}
fi
}
PACKAGES =+ "${PN}-fstools ${PN}-adbd"
RDEPENDS:${BPN} = "${BPN}-conf p7zip"
FILES:${PN}-adbd = "\
${bindir}/adbd \
${systemd_unitdir}/system/android-tools-adbd.service \
"
FILES:${PN}-fstools = "\
${bindir}/ext2simg \
${bindir}/ext4fixup \
${bindir}/img2simg \
${bindir}/make_ext4fs \
${bindir}/simg2img \
${bindir}/simg2simg \
${bindir}/simg_dump \
${bindir}/mkuserimg \
"
FILES:${PN} += "${libdir}/android ${libdir}/android/*"
BBCLASSEXTEND = "native"
android_tools_enable_devmode() {
touch ${IMAGE_ROOTFS}/var/usb-debugging-enabled
}
ROOTFS_POSTPROCESS_COMMAND_${PN}-adbd += "${@bb.utils.contains("USB_DEBUGGING_ENABLED", "1", "android_tools_enable_devmode;", "", d)}"