aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Android.bp178
-rw-r--r--LICENSE27
-rw-r--r--METADATA14
-rw-r--r--MODULE_LICENSE_CHROME0
-rw-r--r--OWNERS15
-rw-r--r--aosp/include/base/check.h22
-rw-r--r--aosp/include/base/check_op.h24
-rw-r--r--aosp/include/base/containers/cxx20_erase.h22
-rw-r--r--aosp/include/base/notreached.h22
-rw-r--r--aosp/include/build/buildflag.h47
l---------aosp/include/components/zucchini/abs32_utils.h1
l---------aosp/include/components/zucchini/address_translator.h1
l---------aosp/include/components/zucchini/algorithm.h1
l---------aosp/include/components/zucchini/arm_utils.h1
l---------aosp/include/components/zucchini/binary_data_histogram.h1
l---------aosp/include/components/zucchini/buffer_sink.h1
l---------aosp/include/components/zucchini/buffer_source.h1
l---------aosp/include/components/zucchini/buffer_view.h1
l---------aosp/include/components/zucchini/buildflags.h1
l---------aosp/include/components/zucchini/crc32.h1
l---------aosp/include/components/zucchini/disassembler.h1
l---------aosp/include/components/zucchini/disassembler_dex.h1
l---------aosp/include/components/zucchini/disassembler_elf.h1
l---------aosp/include/components/zucchini/disassembler_no_op.h1
l---------aosp/include/components/zucchini/disassembler_win32.h1
l---------aosp/include/components/zucchini/disassembler_ztf.h1
l---------aosp/include/components/zucchini/element_detection.h1
l---------aosp/include/components/zucchini/encoded_view.h1
l---------aosp/include/components/zucchini/ensemble_matcher.h1
l---------aosp/include/components/zucchini/equivalence_map.h1
l---------aosp/include/components/zucchini/heuristic_ensemble_matcher.h1
l---------aosp/include/components/zucchini/image_index.h1
l---------aosp/include/components/zucchini/image_utils.h1
l---------aosp/include/components/zucchini/imposed_ensemble_matcher.h1
l---------aosp/include/components/zucchini/io_utils.h1
l---------aosp/include/components/zucchini/main_utils.h1
l---------aosp/include/components/zucchini/mapped_file.h1
l---------aosp/include/components/zucchini/patch_reader.h1
l---------aosp/include/components/zucchini/patch_utils.h1
l---------aosp/include/components/zucchini/patch_writer.h1
l---------aosp/include/components/zucchini/reference_bytes_mixer.h1
l---------aosp/include/components/zucchini/reference_set.h1
l---------aosp/include/components/zucchini/rel32_finder.h1
l---------aosp/include/components/zucchini/rel32_utils.h1
l---------aosp/include/components/zucchini/reloc_elf.h1
l---------aosp/include/components/zucchini/reloc_win32.h1
l---------aosp/include/components/zucchini/suffix_array.h1
l---------aosp/include/components/zucchini/target_pool.h1
l---------aosp/include/components/zucchini/targets_affinity.h1
l---------aosp/include/components/zucchini/test_disassembler.h1
l---------aosp/include/components/zucchini/test_reference_reader.h1
l---------aosp/include/components/zucchini/test_utils.h1
l---------aosp/include/components/zucchini/type_dex.h1
l---------aosp/include/components/zucchini/type_elf.h1
l---------aosp/include/components/zucchini/type_win_pe.h1
l---------aosp/include/components/zucchini/type_ztf.h1
l---------aosp/include/components/zucchini/typed_value.h1
l---------aosp/include/components/zucchini/version_info.h1
l---------aosp/include/components/zucchini/zucchini.h1
l---------aosp/include/components/zucchini/zucchini_apply.h1
l---------aosp/include/components/zucchini/zucchini_commands.h1
l---------aosp/include/components/zucchini/zucchini_gen.h1
l---------aosp/include/components/zucchini/zucchini_integration.h1
l---------aosp/include/components/zucchini/zucchini_tools.h1
-rw-r--r--aosp/include/third_party/abseil-cpp/absl/types/optional.h28
-rw-r--r--buildflags.h14
-rw-r--r--mapped_file.cc2
-rw-r--r--zucchini_main_aosp.cc69
68 files changed, 533 insertions, 5 deletions
diff --git a/Android.bp b/Android.bp
new file mode 100644
index 0000000..254a3d4
--- /dev/null
+++ b/Android.bp
@@ -0,0 +1,178 @@
+
+package {
+ default_applicable_licenses: ["external_zucchini_license"],
+}
+
+// Added automatically by a large-scale-change
+// See: http://go/android-license-faq
+license {
+ name: "external_zucchini_license",
+ visibility: [":__subpackages__"],
+ license_kinds: [
+ "legacy_notice",
+ ],
+ license_text: [
+ "LICENSE",
+ ],
+}
+
+filegroup {
+ name: "libzucchini_srcs",
+
+ srcs: [
+ "abs32_utils.cc",
+ "address_translator.cc",
+ "arm_utils.cc",
+ "binary_data_histogram.cc",
+ "buffer_sink.cc",
+ "buffer_source.cc",
+ "crc32.cc",
+ "disassembler.cc",
+ "disassembler_dex.cc",
+ "disassembler_elf.cc",
+ "disassembler_no_op.cc",
+ "disassembler_win32.cc",
+ "disassembler_ztf.cc",
+ "element_detection.cc",
+ "encoded_view.cc",
+ "ensemble_matcher.cc",
+ "equivalence_map.cc",
+ "heuristic_ensemble_matcher.cc",
+ "image_index.cc",
+ "imposed_ensemble_matcher.cc",
+ "io_utils.cc",
+ "mapped_file.cc",
+ "patch_reader.cc",
+ "patch_writer.cc",
+ "reference_bytes_mixer.cc",
+ "reference_set.cc",
+ "rel32_finder.cc",
+ "rel32_utils.cc",
+ "reloc_elf.cc",
+ "reloc_win32.cc",
+ "target_pool.cc",
+ "targets_affinity.cc",
+ "zucchini_apply.cc",
+ "zucchini_gen.cc",
+ "zucchini_tools.cc",
+ ],
+}
+
+filegroup {
+ name: "zucchini_srcs",
+ srcs: [
+ "main_utils.cc",
+ "zucchini_commands.cc",
+ "zucchini_integration.cc",
+ "zucchini_main_aosp.cc",
+ ],
+}
+
+filegroup {
+ name: "libzucchini_headers",
+ srcs: [
+ "abs32_utils.h",
+ "address_translator.h",
+ "algorithm.h",
+ "arm_utils.h",
+ "binary_data_histogram.h",
+ "buffer_sink.h",
+ "buffer_source.h",
+ "buffer_view.h",
+ "crc32.h",
+ "disassembler.h",
+ "disassembler_dex.h",
+ "disassembler_elf.h",
+ "disassembler_no_op.h",
+ "disassembler_win32.h",
+ "disassembler_ztf.h",
+ "element_detection.h",
+ "encoded_view.h",
+ "ensemble_matcher.h",
+ "equivalence_map.h",
+ "heuristic_ensemble_matcher.h",
+ "image_index.h",
+ "image_utils.h",
+ "imposed_ensemble_matcher.h",
+ "io_utils.h",
+ "main_utils.h",
+ "mapped_file.h",
+ "patch_reader.h",
+ "patch_utils.h",
+ "patch_writer.h",
+ "reference_bytes_mixer.h",
+ "reference_set.h",
+ "rel32_finder.h",
+ "rel32_utils.h",
+ "reloc_elf.h",
+ "reloc_win32.h",
+ "suffix_array.h",
+ "target_pool.h",
+ "targets_affinity.h",
+ "test_disassembler.h",
+ "test_reference_reader.h",
+ "test_utils.h",
+ "type_dex.h",
+ "type_elf.h",
+ "type_win_pe.h",
+ "type_ztf.h",
+ "typed_value.h",
+ "zucchini.h",
+ "zucchini_apply.h",
+ "zucchini_commands.h",
+ "zucchini_gen.h",
+ "zucchini_integration.h",
+ "zucchini_tools.h",
+ ],
+}
+
+cc_library {
+ name: "libzucchini",
+ host_supported: true,
+ device_supported: true,
+ recovery_available: true,
+ // Need this to ensure that the generated headers are used,
+ // instead of loacl ones. As the generated headers contain
+ // incorrect include paths
+ include_build_directory: false,
+ srcs: [":libzucchini_srcs"],
+ local_include_dirs: ["aosp/include"],
+ export_include_dirs: [
+ "aosp/include/components",
+ "aosp/include/",
+ ],
+ static_libs: [
+ "libchrome",
+ "libcutils",
+ ],
+ shared_libs: [
+ "liblog",
+ "libbase",
+ ],
+ cflags: [
+ "-Wno-unused-parameter",
+ ],
+ visibility: [
+ "//external/puffin:__subpackages__",
+ "//system/update_engine:__subpackages__",
+ ],
+}
+
+cc_binary {
+ name: "zucchini",
+ host_supported: true,
+ device_supported: true,
+ srcs: [":zucchini_srcs"],
+ include_build_directory: false,
+ local_include_dirs: ["aosp/include"],
+ static_libs: [
+ "libchrome",
+ "libcutils",
+ "libzucchini",
+ "liblog",
+ "libbase",
+ ],
+ cflags: [
+ "-Wno-unused-parameter",
+ ],
+}
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..a32e00c
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,27 @@
+// Copyright 2015 The Chromium Authors. 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.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// 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.
diff --git a/METADATA b/METADATA
new file mode 100644
index 0000000..b94b43e
--- /dev/null
+++ b/METADATA
@@ -0,0 +1,14 @@
+name: "zucchini"
+description:
+ "zucchini is an diffing algorithm for executables such as ELF, ARM, EXE, "
+ "APK, etc."
+
+third_party {
+ url {
+ type: GIT
+ value: "https://chromium.googlesource.com/chromium/src/components/zucchini/"
+ }
+ version: "769128e925d4591347c4f28ccb1e3e552af5f13b"
+ last_upgrade_date { year: 2021 month: 7 day: 26 }
+ license_type: NOTICE
+}
diff --git a/MODULE_LICENSE_CHROME b/MODULE_LICENSE_CHROME
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/MODULE_LICENSE_CHROME
diff --git a/OWNERS b/OWNERS
index 1eb740b..411aeff 100644
--- a/OWNERS
+++ b/OWNERS
@@ -1,4 +1,11 @@
-etiennep@chromium.org
-huangs@chromium.org
-grt@chromium.org
-wfh@chromium.org
+
+# Chromium owners
+
+huangs@google.com
+
+
+# AOSP Owners
+
+zhangkelvin@google.com
+xunchang@google.com
+
diff --git a/aosp/include/base/check.h b/aosp/include/base/check.h
new file mode 100644
index 0000000..3ed2e04
--- /dev/null
+++ b/aosp/include/base/check.h
@@ -0,0 +1,22 @@
+//
+// Copyright (C) 2021 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.
+//
+
+#ifndef __ZUCCHINI_AOSP_BASE_CHECK_H
+#define __ZUCCHINI_AOSP_BASE_CHECK_H
+
+#include <base/logging.h>
+
+#endif /* __ZUCCHINI_AOSP_BASE_CHECK_H */
diff --git a/aosp/include/base/check_op.h b/aosp/include/base/check_op.h
new file mode 100644
index 0000000..47162e6
--- /dev/null
+++ b/aosp/include/base/check_op.h
@@ -0,0 +1,24 @@
+//
+// Copyright (C) 2021 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.
+//
+
+#ifndef __ZUCCHINI_AOSP_BASE_CHECK_OP_H
+#define __ZUCCHINI_AOSP_BASE_CHECK_OP_H
+
+#include <base/logging.h>
+
+#define FLAG_WIN_SHARE_DELETE FLAG_SHARE_DELETE
+
+#endif /* __ZUCCHINI_AOSP_BASE_CHECK_OP_H */
diff --git a/aosp/include/base/containers/cxx20_erase.h b/aosp/include/base/containers/cxx20_erase.h
new file mode 100644
index 0000000..2fac314
--- /dev/null
+++ b/aosp/include/base/containers/cxx20_erase.h
@@ -0,0 +1,22 @@
+//
+// Copyright (C) 2021 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.
+//
+
+#ifndef __ZUCCHINI_AOSP_BASE_CONTAINERS_CXX20_ERASE_H
+#define __ZUCCHINI_AOSP_BASE_CONTAINERS_CXX20_ERASE_H
+
+#include <base/stl_util.h>
+
+#endif
diff --git a/aosp/include/base/notreached.h b/aosp/include/base/notreached.h
new file mode 100644
index 0000000..631285c
--- /dev/null
+++ b/aosp/include/base/notreached.h
@@ -0,0 +1,22 @@
+//
+// Copyright (C) 2021 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.
+//
+
+#ifndef __ZUCCHINI_AOSP_BASE_NOTREACHED_H
+#define __ZUCCHINI_AOSP_BASE_NOTREACHED_H
+
+#include <base/logging.h>
+
+#endif /* __ZUCCHINI_AOSP_BASE_NOTREACHED_H */
diff --git a/aosp/include/build/buildflag.h b/aosp/include/build/buildflag.h
new file mode 100644
index 0000000..8d7c0e0
--- /dev/null
+++ b/aosp/include/build/buildflag.h
@@ -0,0 +1,47 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef BUILD_BUILDFLAG_H_
+#define BUILD_BUILDFLAG_H_
+
+// These macros un-mangle the names of the build flags in a way that looks
+// natural, and gives errors if the flag is not defined. Normally in the
+// preprocessor it's easy to make mistakes that interpret "you haven't done
+// the setup to know what the flag is" as "flag is off". Normally you would
+// include the generated header rather than include this file directly.
+//
+// This is for use with generated headers. See build/buildflag_header.gni.
+
+// This dance of two macros does a concatenation of two preprocessor args using
+// ## doubly indirectly because using ## directly prevents macros in that
+// parameter from being expanded.
+#define BUILDFLAG_CAT_INDIRECT(a, b) a##b
+#define BUILDFLAG_CAT(a, b) BUILDFLAG_CAT_INDIRECT(a, b)
+
+// Accessor for build flags.
+//
+// To test for a value, if the build file specifies:
+//
+// ENABLE_FOO=true
+//
+// Then you would check at build-time in source code with:
+//
+// #include "foo_flags.h" // The header the build file specified.
+//
+// #if BUILDFLAG(ENABLE_FOO)
+// ...
+// #endif
+//
+// There will no #define called ENABLE_FOO so if you accidentally test for
+// whether that is defined, it will always be negative. You can also use
+// the value in expressions:
+//
+// const char kSpamServerName[] = BUILDFLAG(SPAM_SERVER_NAME);
+//
+// Because the flag is accessed as a preprocessor macro with (), an error
+// will be thrown if the proper header defining the internal flag value has
+// not been included.
+#define BUILDFLAG(flag) (BUILDFLAG_CAT(BUILDFLAG_INTERNAL_, flag)())
+
+#endif // BUILD_BUILDFLAG_H_
diff --git a/aosp/include/components/zucchini/abs32_utils.h b/aosp/include/components/zucchini/abs32_utils.h
new file mode 120000
index 0000000..5a1a56a
--- /dev/null
+++ b/aosp/include/components/zucchini/abs32_utils.h
@@ -0,0 +1 @@
+../../../../abs32_utils.h \ No newline at end of file
diff --git a/aosp/include/components/zucchini/address_translator.h b/aosp/include/components/zucchini/address_translator.h
new file mode 120000
index 0000000..f302a8f
--- /dev/null
+++ b/aosp/include/components/zucchini/address_translator.h
@@ -0,0 +1 @@
+../../../../address_translator.h \ No newline at end of file
diff --git a/aosp/include/components/zucchini/algorithm.h b/aosp/include/components/zucchini/algorithm.h
new file mode 120000
index 0000000..9f91466
--- /dev/null
+++ b/aosp/include/components/zucchini/algorithm.h
@@ -0,0 +1 @@
+../../../../algorithm.h \ No newline at end of file
diff --git a/aosp/include/components/zucchini/arm_utils.h b/aosp/include/components/zucchini/arm_utils.h
new file mode 120000
index 0000000..12e94ec
--- /dev/null
+++ b/aosp/include/components/zucchini/arm_utils.h
@@ -0,0 +1 @@
+../../../../arm_utils.h \ No newline at end of file
diff --git a/aosp/include/components/zucchini/binary_data_histogram.h b/aosp/include/components/zucchini/binary_data_histogram.h
new file mode 120000
index 0000000..5560310
--- /dev/null
+++ b/aosp/include/components/zucchini/binary_data_histogram.h
@@ -0,0 +1 @@
+../../../../binary_data_histogram.h \ No newline at end of file
diff --git a/aosp/include/components/zucchini/buffer_sink.h b/aosp/include/components/zucchini/buffer_sink.h
new file mode 120000
index 0000000..9c2db50
--- /dev/null
+++ b/aosp/include/components/zucchini/buffer_sink.h
@@ -0,0 +1 @@
+../../../../buffer_sink.h \ No newline at end of file
diff --git a/aosp/include/components/zucchini/buffer_source.h b/aosp/include/components/zucchini/buffer_source.h
new file mode 120000
index 0000000..08e30e4
--- /dev/null
+++ b/aosp/include/components/zucchini/buffer_source.h
@@ -0,0 +1 @@
+../../../../buffer_source.h \ No newline at end of file
diff --git a/aosp/include/components/zucchini/buffer_view.h b/aosp/include/components/zucchini/buffer_view.h
new file mode 120000
index 0000000..75387cf
--- /dev/null
+++ b/aosp/include/components/zucchini/buffer_view.h
@@ -0,0 +1 @@
+../../../../buffer_view.h \ No newline at end of file
diff --git a/aosp/include/components/zucchini/buildflags.h b/aosp/include/components/zucchini/buildflags.h
new file mode 120000
index 0000000..521bf21
--- /dev/null
+++ b/aosp/include/components/zucchini/buildflags.h
@@ -0,0 +1 @@
+../../../../buildflags.h \ No newline at end of file
diff --git a/aosp/include/components/zucchini/crc32.h b/aosp/include/components/zucchini/crc32.h
new file mode 120000
index 0000000..d80e882
--- /dev/null
+++ b/aosp/include/components/zucchini/crc32.h
@@ -0,0 +1 @@
+../../../../crc32.h \ No newline at end of file
diff --git a/aosp/include/components/zucchini/disassembler.h b/aosp/include/components/zucchini/disassembler.h
new file mode 120000
index 0000000..536a3d3
--- /dev/null
+++ b/aosp/include/components/zucchini/disassembler.h
@@ -0,0 +1 @@
+../../../../disassembler.h \ No newline at end of file
diff --git a/aosp/include/components/zucchini/disassembler_dex.h b/aosp/include/components/zucchini/disassembler_dex.h
new file mode 120000
index 0000000..d2e42ab
--- /dev/null
+++ b/aosp/include/components/zucchini/disassembler_dex.h
@@ -0,0 +1 @@
+../../../../disassembler_dex.h \ No newline at end of file
diff --git a/aosp/include/components/zucchini/disassembler_elf.h b/aosp/include/components/zucchini/disassembler_elf.h
new file mode 120000
index 0000000..e2e5f92
--- /dev/null
+++ b/aosp/include/components/zucchini/disassembler_elf.h
@@ -0,0 +1 @@
+../../../../disassembler_elf.h \ No newline at end of file
diff --git a/aosp/include/components/zucchini/disassembler_no_op.h b/aosp/include/components/zucchini/disassembler_no_op.h
new file mode 120000
index 0000000..c016e24
--- /dev/null
+++ b/aosp/include/components/zucchini/disassembler_no_op.h
@@ -0,0 +1 @@
+../../../../disassembler_no_op.h \ No newline at end of file
diff --git a/aosp/include/components/zucchini/disassembler_win32.h b/aosp/include/components/zucchini/disassembler_win32.h
new file mode 120000
index 0000000..6a53082
--- /dev/null
+++ b/aosp/include/components/zucchini/disassembler_win32.h
@@ -0,0 +1 @@
+../../../../disassembler_win32.h \ No newline at end of file
diff --git a/aosp/include/components/zucchini/disassembler_ztf.h b/aosp/include/components/zucchini/disassembler_ztf.h
new file mode 120000
index 0000000..501c313
--- /dev/null
+++ b/aosp/include/components/zucchini/disassembler_ztf.h
@@ -0,0 +1 @@
+../../../../disassembler_ztf.h \ No newline at end of file
diff --git a/aosp/include/components/zucchini/element_detection.h b/aosp/include/components/zucchini/element_detection.h
new file mode 120000
index 0000000..84129ba
--- /dev/null
+++ b/aosp/include/components/zucchini/element_detection.h
@@ -0,0 +1 @@
+../../../../element_detection.h \ No newline at end of file
diff --git a/aosp/include/components/zucchini/encoded_view.h b/aosp/include/components/zucchini/encoded_view.h
new file mode 120000
index 0000000..a60af6d
--- /dev/null
+++ b/aosp/include/components/zucchini/encoded_view.h
@@ -0,0 +1 @@
+../../../../encoded_view.h \ No newline at end of file
diff --git a/aosp/include/components/zucchini/ensemble_matcher.h b/aosp/include/components/zucchini/ensemble_matcher.h
new file mode 120000
index 0000000..7d51538
--- /dev/null
+++ b/aosp/include/components/zucchini/ensemble_matcher.h
@@ -0,0 +1 @@
+../../../../ensemble_matcher.h \ No newline at end of file
diff --git a/aosp/include/components/zucchini/equivalence_map.h b/aosp/include/components/zucchini/equivalence_map.h
new file mode 120000
index 0000000..6d67205
--- /dev/null
+++ b/aosp/include/components/zucchini/equivalence_map.h
@@ -0,0 +1 @@
+../../../../equivalence_map.h \ No newline at end of file
diff --git a/aosp/include/components/zucchini/heuristic_ensemble_matcher.h b/aosp/include/components/zucchini/heuristic_ensemble_matcher.h
new file mode 120000
index 0000000..bfadfc9
--- /dev/null
+++ b/aosp/include/components/zucchini/heuristic_ensemble_matcher.h
@@ -0,0 +1 @@
+../../../../heuristic_ensemble_matcher.h \ No newline at end of file
diff --git a/aosp/include/components/zucchini/image_index.h b/aosp/include/components/zucchini/image_index.h
new file mode 120000
index 0000000..80fdb0a
--- /dev/null
+++ b/aosp/include/components/zucchini/image_index.h
@@ -0,0 +1 @@
+../../../../image_index.h \ No newline at end of file
diff --git a/aosp/include/components/zucchini/image_utils.h b/aosp/include/components/zucchini/image_utils.h
new file mode 120000
index 0000000..7f4e142
--- /dev/null
+++ b/aosp/include/components/zucchini/image_utils.h
@@ -0,0 +1 @@
+../../../../image_utils.h \ No newline at end of file
diff --git a/aosp/include/components/zucchini/imposed_ensemble_matcher.h b/aosp/include/components/zucchini/imposed_ensemble_matcher.h
new file mode 120000
index 0000000..0a0642b
--- /dev/null
+++ b/aosp/include/components/zucchini/imposed_ensemble_matcher.h
@@ -0,0 +1 @@
+../../../../imposed_ensemble_matcher.h \ No newline at end of file
diff --git a/aosp/include/components/zucchini/io_utils.h b/aosp/include/components/zucchini/io_utils.h
new file mode 120000
index 0000000..671200e
--- /dev/null
+++ b/aosp/include/components/zucchini/io_utils.h
@@ -0,0 +1 @@
+../../../../io_utils.h \ No newline at end of file
diff --git a/aosp/include/components/zucchini/main_utils.h b/aosp/include/components/zucchini/main_utils.h
new file mode 120000
index 0000000..9f56dda
--- /dev/null
+++ b/aosp/include/components/zucchini/main_utils.h
@@ -0,0 +1 @@
+../../../../main_utils.h \ No newline at end of file
diff --git a/aosp/include/components/zucchini/mapped_file.h b/aosp/include/components/zucchini/mapped_file.h
new file mode 120000
index 0000000..a5440bb
--- /dev/null
+++ b/aosp/include/components/zucchini/mapped_file.h
@@ -0,0 +1 @@
+../../../../mapped_file.h \ No newline at end of file
diff --git a/aosp/include/components/zucchini/patch_reader.h b/aosp/include/components/zucchini/patch_reader.h
new file mode 120000
index 0000000..0e7e2ec
--- /dev/null
+++ b/aosp/include/components/zucchini/patch_reader.h
@@ -0,0 +1 @@
+../../../../patch_reader.h \ No newline at end of file
diff --git a/aosp/include/components/zucchini/patch_utils.h b/aosp/include/components/zucchini/patch_utils.h
new file mode 120000
index 0000000..930f147
--- /dev/null
+++ b/aosp/include/components/zucchini/patch_utils.h
@@ -0,0 +1 @@
+../../../../patch_utils.h \ No newline at end of file
diff --git a/aosp/include/components/zucchini/patch_writer.h b/aosp/include/components/zucchini/patch_writer.h
new file mode 120000
index 0000000..ebf0b13
--- /dev/null
+++ b/aosp/include/components/zucchini/patch_writer.h
@@ -0,0 +1 @@
+../../../../patch_writer.h \ No newline at end of file
diff --git a/aosp/include/components/zucchini/reference_bytes_mixer.h b/aosp/include/components/zucchini/reference_bytes_mixer.h
new file mode 120000
index 0000000..9c7b310
--- /dev/null
+++ b/aosp/include/components/zucchini/reference_bytes_mixer.h
@@ -0,0 +1 @@
+../../../../reference_bytes_mixer.h \ No newline at end of file
diff --git a/aosp/include/components/zucchini/reference_set.h b/aosp/include/components/zucchini/reference_set.h
new file mode 120000
index 0000000..3294dbb
--- /dev/null
+++ b/aosp/include/components/zucchini/reference_set.h
@@ -0,0 +1 @@
+../../../../reference_set.h \ No newline at end of file
diff --git a/aosp/include/components/zucchini/rel32_finder.h b/aosp/include/components/zucchini/rel32_finder.h
new file mode 120000
index 0000000..58a5f3b
--- /dev/null
+++ b/aosp/include/components/zucchini/rel32_finder.h
@@ -0,0 +1 @@
+../../../../rel32_finder.h \ No newline at end of file
diff --git a/aosp/include/components/zucchini/rel32_utils.h b/aosp/include/components/zucchini/rel32_utils.h
new file mode 120000
index 0000000..a411940
--- /dev/null
+++ b/aosp/include/components/zucchini/rel32_utils.h
@@ -0,0 +1 @@
+../../../../rel32_utils.h \ No newline at end of file
diff --git a/aosp/include/components/zucchini/reloc_elf.h b/aosp/include/components/zucchini/reloc_elf.h
new file mode 120000
index 0000000..5dc8c30
--- /dev/null
+++ b/aosp/include/components/zucchini/reloc_elf.h
@@ -0,0 +1 @@
+../../../../reloc_elf.h \ No newline at end of file
diff --git a/aosp/include/components/zucchini/reloc_win32.h b/aosp/include/components/zucchini/reloc_win32.h
new file mode 120000
index 0000000..36b0152
--- /dev/null
+++ b/aosp/include/components/zucchini/reloc_win32.h
@@ -0,0 +1 @@
+../../../../reloc_win32.h \ No newline at end of file
diff --git a/aosp/include/components/zucchini/suffix_array.h b/aosp/include/components/zucchini/suffix_array.h
new file mode 120000
index 0000000..3116b0f
--- /dev/null
+++ b/aosp/include/components/zucchini/suffix_array.h
@@ -0,0 +1 @@
+../../../../suffix_array.h \ No newline at end of file
diff --git a/aosp/include/components/zucchini/target_pool.h b/aosp/include/components/zucchini/target_pool.h
new file mode 120000
index 0000000..ca03e3e
--- /dev/null
+++ b/aosp/include/components/zucchini/target_pool.h
@@ -0,0 +1 @@
+../../../../target_pool.h \ No newline at end of file
diff --git a/aosp/include/components/zucchini/targets_affinity.h b/aosp/include/components/zucchini/targets_affinity.h
new file mode 120000
index 0000000..a18787d
--- /dev/null
+++ b/aosp/include/components/zucchini/targets_affinity.h
@@ -0,0 +1 @@
+../../../../targets_affinity.h \ No newline at end of file
diff --git a/aosp/include/components/zucchini/test_disassembler.h b/aosp/include/components/zucchini/test_disassembler.h
new file mode 120000
index 0000000..7e67faf
--- /dev/null
+++ b/aosp/include/components/zucchini/test_disassembler.h
@@ -0,0 +1 @@
+../../../../test_disassembler.h \ No newline at end of file
diff --git a/aosp/include/components/zucchini/test_reference_reader.h b/aosp/include/components/zucchini/test_reference_reader.h
new file mode 120000
index 0000000..814b366
--- /dev/null
+++ b/aosp/include/components/zucchini/test_reference_reader.h
@@ -0,0 +1 @@
+../../../../test_reference_reader.h \ No newline at end of file
diff --git a/aosp/include/components/zucchini/test_utils.h b/aosp/include/components/zucchini/test_utils.h
new file mode 120000
index 0000000..0db69e3
--- /dev/null
+++ b/aosp/include/components/zucchini/test_utils.h
@@ -0,0 +1 @@
+../../../../test_utils.h \ No newline at end of file
diff --git a/aosp/include/components/zucchini/type_dex.h b/aosp/include/components/zucchini/type_dex.h
new file mode 120000
index 0000000..2085b37
--- /dev/null
+++ b/aosp/include/components/zucchini/type_dex.h
@@ -0,0 +1 @@
+../../../../type_dex.h \ No newline at end of file
diff --git a/aosp/include/components/zucchini/type_elf.h b/aosp/include/components/zucchini/type_elf.h
new file mode 120000
index 0000000..d9b55d1
--- /dev/null
+++ b/aosp/include/components/zucchini/type_elf.h
@@ -0,0 +1 @@
+../../../../type_elf.h \ No newline at end of file
diff --git a/aosp/include/components/zucchini/type_win_pe.h b/aosp/include/components/zucchini/type_win_pe.h
new file mode 120000
index 0000000..1d8790f
--- /dev/null
+++ b/aosp/include/components/zucchini/type_win_pe.h
@@ -0,0 +1 @@
+../../../../type_win_pe.h \ No newline at end of file
diff --git a/aosp/include/components/zucchini/type_ztf.h b/aosp/include/components/zucchini/type_ztf.h
new file mode 120000
index 0000000..e44b5f7
--- /dev/null
+++ b/aosp/include/components/zucchini/type_ztf.h
@@ -0,0 +1 @@
+../../../../type_ztf.h \ No newline at end of file
diff --git a/aosp/include/components/zucchini/typed_value.h b/aosp/include/components/zucchini/typed_value.h
new file mode 120000
index 0000000..fc7f2b7
--- /dev/null
+++ b/aosp/include/components/zucchini/typed_value.h
@@ -0,0 +1 @@
+../../../../typed_value.h \ No newline at end of file
diff --git a/aosp/include/components/zucchini/version_info.h b/aosp/include/components/zucchini/version_info.h
new file mode 120000
index 0000000..be765ba
--- /dev/null
+++ b/aosp/include/components/zucchini/version_info.h
@@ -0,0 +1 @@
+../../../../version_info.h \ No newline at end of file
diff --git a/aosp/include/components/zucchini/zucchini.h b/aosp/include/components/zucchini/zucchini.h
new file mode 120000
index 0000000..20426f6
--- /dev/null
+++ b/aosp/include/components/zucchini/zucchini.h
@@ -0,0 +1 @@
+../../../../zucchini.h \ No newline at end of file
diff --git a/aosp/include/components/zucchini/zucchini_apply.h b/aosp/include/components/zucchini/zucchini_apply.h
new file mode 120000
index 0000000..2a5495b
--- /dev/null
+++ b/aosp/include/components/zucchini/zucchini_apply.h
@@ -0,0 +1 @@
+../../../../zucchini_apply.h \ No newline at end of file
diff --git a/aosp/include/components/zucchini/zucchini_commands.h b/aosp/include/components/zucchini/zucchini_commands.h
new file mode 120000
index 0000000..c03fcd7
--- /dev/null
+++ b/aosp/include/components/zucchini/zucchini_commands.h
@@ -0,0 +1 @@
+../../../../zucchini_commands.h \ No newline at end of file
diff --git a/aosp/include/components/zucchini/zucchini_gen.h b/aosp/include/components/zucchini/zucchini_gen.h
new file mode 120000
index 0000000..66bf222
--- /dev/null
+++ b/aosp/include/components/zucchini/zucchini_gen.h
@@ -0,0 +1 @@
+../../../../zucchini_gen.h \ No newline at end of file
diff --git a/aosp/include/components/zucchini/zucchini_integration.h b/aosp/include/components/zucchini/zucchini_integration.h
new file mode 120000
index 0000000..028a91b
--- /dev/null
+++ b/aosp/include/components/zucchini/zucchini_integration.h
@@ -0,0 +1 @@
+../../../../zucchini_integration.h \ No newline at end of file
diff --git a/aosp/include/components/zucchini/zucchini_tools.h b/aosp/include/components/zucchini/zucchini_tools.h
new file mode 120000
index 0000000..3042827
--- /dev/null
+++ b/aosp/include/components/zucchini/zucchini_tools.h
@@ -0,0 +1 @@
+../../../../zucchini_tools.h \ No newline at end of file
diff --git a/aosp/include/third_party/abseil-cpp/absl/types/optional.h b/aosp/include/third_party/abseil-cpp/absl/types/optional.h
new file mode 100644
index 0000000..3321c72
--- /dev/null
+++ b/aosp/include/third_party/abseil-cpp/absl/types/optional.h
@@ -0,0 +1,28 @@
+//
+// Copyright (C) 2021 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.
+//
+
+#ifndef __ZUCCHINI_AOSP_ABSL_OPTIONAL_H
+#define __ZUCCHINI_AOSP_ABSL_OPTIONAL_H
+
+#include <optional>
+
+namespace absl {
+ template <typename T> using optional = std::optional<T>;
+ inline constexpr auto nullopt = std::nullopt;
+}
+
+#endif
+
diff --git a/buildflags.h b/buildflags.h
new file mode 100644
index 0000000..2b63e59
--- /dev/null
+++ b/buildflags.h
@@ -0,0 +1,14 @@
+// Generated by build/write_buildflag_header.py
+// From "//components/zucchini:buildflags"
+
+#ifndef COMPONENTS_ZUCCHINI_BUILDFLAGS_H_
+#define COMPONENTS_ZUCCHINI_BUILDFLAGS_H_
+
+#include "build/buildflag.h"
+
+#define BUILDFLAG_INTERNAL_ENABLE_DEX() (1)
+#define BUILDFLAG_INTERNAL_ENABLE_ELF() (1)
+#define BUILDFLAG_INTERNAL_ENABLE_WIN() (0)
+#define BUILDFLAG_INTERNAL_ENABLE_ZTF() (0)
+
+#endif // COMPONENTS_ZUCCHINI_BUILDFLAGS_H_
diff --git a/mapped_file.cc b/mapped_file.cc
index a742414..2ea973c 100644
--- a/mapped_file.cc
+++ b/mapped_file.cc
@@ -49,7 +49,7 @@ MappedFileWriter::MappedFileWriter(const base::FilePath& file_path,
MappedFileWriter::~MappedFileWriter() {
if (!HasError() && delete_behavior_ == kManualDeleteOnClose &&
- !file_path_.empty() && !base::DeleteFile(file_path_)) {
+ !file_path_.empty() && !base::DeleteFile(file_path_, false)) {
error_ = "Failed to delete file.";
}
}
diff --git a/zucchini_main_aosp.cc b/zucchini_main_aosp.cc
new file mode 100644
index 0000000..4e410a5
--- /dev/null
+++ b/zucchini_main_aosp.cc
@@ -0,0 +1,69 @@
+//
+// Copyright (C) 2021 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.
+//
+
+// This file is exactly the same as zucchini_main.cc, except with a few fixes
+// that make it compatible with AOSP version of liblog
+
+#include <iostream>
+
+#include "base/command_line.h"
+#include "base/logging.h"
+#include "base/process/memory.h"
+#include "build/build_config.h"
+#include "main_utils.h"
+
+#if defined(OS_WIN)
+#include "base/win/process_startup_helper.h"
+#endif // defined(OS_WIN)
+
+namespace {
+
+void InitLogging() {
+ logging::LoggingSettings settings;
+ settings.logging_dest = logging::LOG_TO_SYSTEM_DEBUG_LOG;
+ // settings.log_file_path = nullptr;
+ settings.lock_log = logging::DONT_LOCK_LOG_FILE;
+ settings.delete_old = logging::APPEND_TO_OLD_LOG_FILE;
+ bool logging_res = logging::InitLogging(settings);
+ CHECK(logging_res);
+}
+
+void InitErrorHandling(const base::CommandLine &command_line) {
+ base::EnableTerminationOnHeapCorruption();
+ base::EnableTerminationOnOutOfMemory();
+#if defined(OS_WIN)
+ base::win::RegisterInvalidParamHandler();
+ base::win::SetupCRT(command_line);
+#endif // defined(OS_WIN)
+}
+
+} // namespace
+
+int main(int argc, const char *argv[]) {
+ // Initialize infrastructure from base.
+ base::CommandLine::Init(argc, argv);
+ const base::CommandLine &command_line =
+ *base::CommandLine::ForCurrentProcess();
+ InitLogging();
+ InitErrorHandling(command_line);
+ zucchini::status::Code status =
+ RunZucchiniCommand(command_line, std::cout, std::cerr);
+ if (!(status == zucchini::status::kStatusSuccess ||
+ status == zucchini::status::kStatusInvalidParam)) {
+ std::cerr << "Failed with code " << static_cast<int>(status) << std::endl;
+ }
+ return static_cast<int>(status);
+}