diff options
author | A. Cody Schuffelen <schuffelen@google.com> | 2023-11-02 19:09:56 -0700 |
---|---|---|
committer | A. Cody Schuffelen <schuffelen@google.com> | 2023-11-07 16:28:47 -0800 |
commit | a1fed775e7d4f0b42082e843d5f7c43ccf7a4e86 (patch) | |
tree | 07cee5ada3a50ee626564ab2ce811550c62153ac | |
parent | 6457e527fc00536289ec85e317794941f55effde (diff) | |
download | sandboxed-api-a1fed775e7d4f0b42082e843d5f7c43ccf7a4e86.tar.gz |
Start a build target for building sandbox2
Initially built only with host musl due to lots of missing stuff from
the old version of glibc used in AOSP.
Test: USE_HOST_MUSL=true m
Bug: b/309695709
Change-Id: I0240059218d87e1883ca5ad153a591fd9ace3d3d
-rw-r--r-- | Android.bp | 84 | ||||
-rw-r--r-- | sandboxed_api/sandbox2/util/syscall_trap.cc | 5 |
2 files changed, 87 insertions, 2 deletions
@@ -20,3 +20,87 @@ package { "//device/google/cuttlefish:__subpackages__", ] } + +cc_defaults { + name: "sandboxed_api_defaults", + device_supported: false, + host_supported: true, +} + +cc_library { + name: "sandboxed_api_proto", + srcs: [ + "sandboxed_api/proto_arg.proto", + "sandboxed_api/sandbox2/comms_test.proto", + "sandboxed_api/sandbox2/forkserver.proto", + "sandboxed_api/sandbox2/logserver.proto", + "sandboxed_api/sandbox2/mount_tree.proto", + "sandboxed_api/sandbox2/violation.proto", + "sandboxed_api/util/status.proto", + ], + proto: { + canonical_path_from_root: false, + export_proto_headers: true, + type: "full", + }, + defaults: ["sandboxed_api_defaults"], +} + +cc_library { + name: "sandboxed_api", + srcs: [ + "sandboxed_api/config.cc", + "sandboxed_api/sandbox2/bpfdisassembler.cc", + "sandboxed_api/sandbox2/buffer.cc", + "sandboxed_api/sandbox2/comms.cc", + "sandboxed_api/sandbox2/ipc.cc", + "sandboxed_api/sandbox2/logserver.cc", + "sandboxed_api/sandbox2/logsink.cc", + "sandboxed_api/sandbox2/mounts.cc", + "sandboxed_api/sandbox2/namespace.cc", + "sandboxed_api/sandbox2/regs.cc", + "sandboxed_api/sandbox2/result.cc", + "sandboxed_api/sandbox2/syscall.cc", + "sandboxed_api/sandbox2/syscall_defs.cc", + "sandboxed_api/sandbox2/util.cc", + "sandboxed_api/sandbox2/util/bpf_helper.c", + "sandboxed_api/sandbox2/util/maps_parser.cc", + "sandboxed_api/sandbox2/util/minielf.cc", + "sandboxed_api/sandbox2/util/syscall_trap.cc", + "sandboxed_api/util/file_helpers.cc", + "sandboxed_api/util/fileops.cc", + "sandboxed_api/util/path.cc", + "sandboxed_api/util/raw_logging.cc", + "sandboxed_api/util/status.cc", + "sandboxed_api/util/strerror.cc", + "sandboxed_api/util/temp_file.cc", + ], + static_libs: [ + "libabsl_host", + "sandboxed_api_proto", + "libprotobuf-cpp-full", + ], + arch: { + x86: { + enabled: false, + }, + }, + target: { + linux_glibc: { + enabled: false, + cflags: [ + // Typo in old glibc + "-DPTRACE_EVENT_SECCOMP=PTRAVE_EVENT_SECCOMP", + ], + }, + linux_musl: { + enabled: true, + }, + }, + cflags: [ + "-Wno-unused-parameter", + "-fbracket-depth=768", // for syscall_defs.cc + ], + defaults: ["sandboxed_api_defaults"], +} + diff --git a/sandboxed_api/sandbox2/util/syscall_trap.cc b/sandboxed_api/sandbox2/util/syscall_trap.cc index 44ed8e4..f9515e8 100644 --- a/sandboxed_api/sandbox2/util/syscall_trap.cc +++ b/sandboxed_api/sandbox2/util/syscall_trap.cc @@ -30,8 +30,9 @@ namespace { #if defined(SAPI_X86_64) constexpr int kRegResult = REG_RAX; constexpr int kRegSyscall = REG_RAX; -constexpr std::array kRegArgs = {REG_RDI, REG_RSI, REG_RDX, - REG_R10, REG_R8, REG_R9}; +// ANDROID: On musl these are distinct enum types. Coerce to int. +constexpr std::array<int, 6> kRegArgs = {REG_RDI, REG_RSI, REG_RDX, + REG_R10, REG_R8, REG_R9}; #elif defined(SAPI_PPC64_LE) constexpr int kRegResult = 3; constexpr int kRegSyscall = 0; |