Add patches to build libunwindstack with libdexfile

The parent CL pulls in libdexfile and its dependencies into Chromium.
This CL adds patches required to make libdexfile compile in Chromium.

Bug: 1365904
Change-Id: I216e978e4906b42ad06205c7d75aec5032180555
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/third_party/libunwindstack/+/3913230
Reviewed-by: Mike Wittman <wittman@chromium.org>
diff --git a/README.chromium b/README.chromium
index 7b57f0f..3411e8a 100644
--- a/README.chromium
+++ b/README.chromium
@@ -160,3 +160,23 @@
   Chrome builds with `-Wextra-semi`, redundant semicolons need to be removed to
   build successfully.
 
+- 0009-disable-thread-annotations.patch
+
+  ART(Android RunTime) builds with `_LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS`
+  flag defined. Chromium's libdexfile and libunwindstack builds as part of
+  a single source_set, defining the flag would turn on safety checks for
+  both libunwindstack and libdexfile, libunwindstack upstream doesn't
+  annotate it's code for thread safety so the build errors out when built
+  with the flag.
+
+- 0010-replace-allocator-destroy-construct-calls.patch
+
+  Replace calls to destroy, construct members of allocator, with call to
+  destroy, construct defined in std::allocator_traits<T>
+
+- 0011-dont-compile-unused-functions.patch
+
+  Some unused symbols don't get eliminated for debug builds, explicitly
+  don't compile the unused sections. Required to make component debug builds
+  compile
+
diff --git a/patches/0003-remove-file-logging.patch b/patches/0003-remove-file-logging.patch
index 4b568a2..4ea0ade 100644
--- a/patches/0003-remove-file-logging.patch
+++ b/patches/0003-remove-file-logging.patch
@@ -1,23 +1,53 @@
-diff --git a/src/android-base/file.cpp b/src/android-base/file.cpp
-index 6321fc624..f36fe9a73 100644
---- a/src/android-base/file.cpp
-+++ b/src/android-base/file.cpp
-@@ -43,11 +43,17 @@
- #define OS_PATH_SEPARATOR '/'
- #endif
- 
--#include "android-base/logging.h"  // and must be after windows.h for ERROR
- #include "android-base/macros.h"   // For TEMP_FAILURE_RETRY on Darwin.
- #include "android-base/unique_fd.h"
- #include "android-base/utf8.h"
- 
+diff --git a/src/android-base/include/android-base/logging.h b/src/android-base/include/android-base/logging.h
+index 179ddf0..2d21638 100644
+--- a/src/android-base/include/android-base/logging.h
++++ b/src/android-base/include/android-base/logging.h
+@@ -218,7 +218,13 @@ struct LogAbortAfterFullExpr {
+ // FATAL it also causes an abort. For example:
+ //
+ //     LOG(FATAL) << "We didn't expect to reach here";
+-#define LOG(severity) LOGGING_PREAMBLE(severity) && LOG_STREAM(severity)
 +class FakeLog {
 + public:
-+  FakeLog operator<<(const char*) { return *this; }
++  template<typename T>
++  FakeLog operator<<(const T&) { return *this; }
 +  operator bool() { return false; }
 +};
-+#define PLOG(x) false && FakeLog()
-+
- namespace {
++#define LOG(severity) false && ::android::base::FakeLog()
  
- #ifdef _WIN32
+ // Checks if we want to log something, and sets up appropriate RAII objects if
+ // so.
+@@ -230,11 +236,7 @@ struct LogAbortAfterFullExpr {
+ 
+ // A variant of LOG that also logs the current errno value. To be used when
+ // library calls fail.
+-#define PLOG(severity)                                                           \
+-  LOGGING_PREAMBLE(severity) &&                                                  \
+-      ::android::base::LogMessage(__FILE__, __LINE__, SEVERITY_LAMBDA(severity), \
+-                                  _LOG_TAG_INTERNAL, errno)                      \
+-          .stream()
++#define PLOG(severity) false && ::android::base::FakeLog()
+ 
+ // Marker that code is yet to be implemented.
+ #define UNIMPLEMENTED(level) \
+@@ -248,9 +250,7 @@ struct LogAbortAfterFullExpr {
+ //       "Check failed: false == true".
+ #define CHECK(x)                                                                                 \
+   LIKELY((x)) || ABORT_AFTER_LOG_FATAL_EXPR(false) ||                                            \
+-      ::android::base::LogMessage(__FILE__, __LINE__, ::android::base::FATAL, _LOG_TAG_INTERNAL, \
+-                                  -1)                                                            \
+-              .stream()                                                                          \
++      ::android::base::FakeLog()                                                                 \
+           << "Check failed: " #x << " "
+ 
+ // clang-format off
+@@ -260,8 +260,7 @@ struct LogAbortAfterFullExpr {
+        UNLIKELY(!(_values.lhs.v OP _values.rhs.v));                                              \
+        /* empty */)                                                                              \
+   ABORT_AFTER_LOG_FATAL                                                                          \
+-  ::android::base::LogMessage(__FILE__, __LINE__, ::android::base::FATAL, _LOG_TAG_INTERNAL, -1) \
+-          .stream()                                                                              \
++  ::android::base::FakeLog()                                                                     \
+       << "Check failed: " << #LHS << " " << #OP << " " << #RHS << " (" #LHS "="                  \
+       << ::android::base::LogNullGuard<decltype(_values.lhs.v)>::Guard(_values.lhs.v)            \
+       << ", " #RHS "="                                                                           \
diff --git a/patches/0004-remove-std-iterator.patch b/patches/0004-remove-std-iterator.patch
index 4a0bf17..c6c955f 100644
--- a/patches/0004-remove-std-iterator.patch
+++ b/patches/0004-remove-std-iterator.patch
@@ -1,11 +1,146 @@
+diff --git a/src/libartbase/base/stl_util.h b/src/libartbase/base/stl_util.h
+index 0ae4fd2..d16b01e 100644
+--- a/src/libartbase/base/stl_util.h
++++ b/src/libartbase/base/stl_util.h
+@@ -156,10 +156,14 @@ static inline std::vector<T*> MakeNonOwningPointerVector(const std::vector<std::
+ }
+ 
+ template <typename IterLeft, typename IterRight>
+-class ZipLeftIter : public std::iterator<
+-                        std::forward_iterator_tag,
+-                        std::pair<typename IterLeft::value_type, typename IterRight::value_type>> {
++class ZipLeftIter {
+  public:
++  using iterator_category = std::forward_iterator_tag;
++  using value_type = std::pair<typename IterLeft::value_type, typename IterRight::value_type>;
++  using difference_type = std::ptrdiff_t;
++  using pointer = std::pair<typename IterLeft::value_type, typename IterRight::value_type>*;
++  using reference = std::pair<typename IterLeft::value_type, typename IterRight::value_type>&;
++
+   ZipLeftIter(IterLeft left, IterRight right) : left_iter_(left), right_iter_(right) {}
+   ZipLeftIter<IterLeft, IterRight>& operator++() {
+     ++left_iter_;
+@@ -186,8 +190,13 @@ class ZipLeftIter : public std::iterator<
+   IterRight right_iter_;
+ };
+ 
+-class CountIter : public std::iterator<std::forward_iterator_tag, size_t, size_t, size_t, size_t> {
++class CountIter {
+  public:
++  using iterator_category = std::forward_iterator_tag;
++  using value_type = size_t;
++  using difference_type = size_t;
++  using pointer = size_t;
++  using reference = size_t;
+   CountIter() : count_(0) {}
+   explicit CountIter(size_t count) : count_(count) {}
+   CountIter& operator++() {
+@@ -238,9 +247,14 @@ static inline IterationRange<CountIter> Range(size_t end) {
+ }
+ 
+ template <typename RealIter, typename Filter>
+-struct FilterIterator
+-    : public std::iterator<std::forward_iterator_tag, typename RealIter::value_type> {
++struct FilterIterator {
+  public:
++  using iterator_category = std::forward_iterator_tag;
++  using value_type = typename RealIter::value_type;
++  using difference_type = std::ptrdiff_t;
++  using pointer = typename RealIter::value_type*;
++  using reference = typename RealIter::value_type&;
++
+   FilterIterator(RealIter rl,
+                  Filter cond,
+                  std::optional<RealIter> end = std::nullopt)
+@@ -324,8 +338,14 @@ SafePrinter<Val> SafePrint(const Val* v) {
+ }
+ 
+ // Helper struct for iterating a split-string without allocation.
+-struct SplitStringIter : public std::iterator<std::forward_iterator_tag, std::string_view> {
++struct SplitStringIter {
+  public:
++  using iterator_category = std::forward_iterator_tag;
++  using value_type = std::string_view;
++  using difference_type = std::ptrdiff_t;
++  using pointer = std::string_view*;
++  using reference = std::string_view&;
++
+   // Direct iterator constructor. The iteration state is only the current index.
+   // We use that with the split char and the full string to get the current and
+   // next segment.
+diff --git a/src/libdexfile/dex/class_accessor.h b/src/libdexfile/dex/class_accessor.h
+index a3ee2bd..7f7cdf6 100644
+--- a/src/libdexfile/dex/class_accessor.h
++++ b/src/libdexfile/dex/class_accessor.h
+@@ -177,11 +177,13 @@ class ClassAccessor {
+   };
+ 
+   template <typename DataType>
+-  class DataIterator : public std::iterator<std::forward_iterator_tag, DataType> {
++  class DataIterator {
+    public:
+-    using value_type = typename std::iterator<std::forward_iterator_tag, DataType>::value_type;
+-    using difference_type =
+-        typename std::iterator<std::forward_iterator_tag, value_type>::difference_type;
++    using iterator_category = std::forward_iterator_tag;
++    using value_type = DataType;
++    using difference_type = std::ptrdiff_t;
++    using pointer = DataType*;
++    using reference = DataType&;
+ 
+     DataIterator(const DexFile& dex_file,
+                  uint32_t position,
+diff --git a/src/libdexfile/dex/class_iterator.h b/src/libdexfile/dex/class_iterator.h
+index 8ed585b..9ace41b 100644
+--- a/src/libdexfile/dex/class_iterator.h
++++ b/src/libdexfile/dex/class_iterator.h
+@@ -41,10 +41,13 @@ class ClassIteratorData {
+ };
+ 
+ // Iterator for visiting classes in a Dex file.
+-class ClassIterator : public std::iterator<std::forward_iterator_tag, ClassIteratorData> {
++class ClassIterator {
+  public:
+-  using value_type = std::iterator<std::forward_iterator_tag, ClassIteratorData>::value_type;
+-  using difference_type = std::iterator<std::forward_iterator_tag, value_type>::difference_type;
++  using iterator_category = std::forward_iterator_tag;
++  using value_type = ClassIteratorData;
++  using difference_type = std::ptrdiff_t;
++  using pointer = ClassIteratorData*;
++  using reference = ClassIteratorData&;
+ 
+   ClassIterator(const DexFile& dex_file, uint32_t class_def_idx)
+       : data_(dex_file, class_def_idx) {}
+diff --git a/src/libdexfile/dex/dex_instruction_iterator.h b/src/libdexfile/dex/dex_instruction_iterator.h
+index 6c7f42a..0ce6c96 100644
+--- a/src/libdexfile/dex/dex_instruction_iterator.h
++++ b/src/libdexfile/dex/dex_instruction_iterator.h
+@@ -57,11 +57,13 @@ class DexInstructionPcPair {
+ };
+ 
+ // Base helper class to prevent duplicated comparators.
+-class DexInstructionIteratorBase : public
+-        std::iterator<std::forward_iterator_tag, DexInstructionPcPair> {
++class DexInstructionIteratorBase {
+  public:
+-  using value_type = std::iterator<std::forward_iterator_tag, DexInstructionPcPair>::value_type;
+-  using difference_type = std::iterator<std::forward_iterator_tag, value_type>::difference_type;
++  using iterator_category = std::forward_iterator_tag;
++  using value_type = DexInstructionPcPair;
++  using difference_type = std::ptrdiff_t;
++  using pointer = DexInstructionPcPair*;
++  using reference = DexInstructionPcPair&;
+ 
+   explicit DexInstructionIteratorBase(const Instruction* inst, uint32_t dex_pc)
+       : data_(reinterpret_cast<const uint16_t*>(inst), dex_pc) {}
 diff --git a/src/libunwindstack/ElfInterfaceArm.h b/src/libunwindstack/ElfInterfaceArm.h
-index 1d71cac..157f31b 100644
+index 6ee6dc9..a2435f2 100644
 --- a/src/libunwindstack/ElfInterfaceArm.h
 +++ b/src/libunwindstack/ElfInterfaceArm.h
-@@ -33,8 +33,14 @@ class ElfInterfaceArm : public ElfInterface32 {
+@@ -32,8 +32,14 @@ class ElfInterfaceArm : public ElfInterface32 {
    ElfInterfaceArm(Memory* memory) : ElfInterface32(memory) {}
    virtual ~ElfInterfaceArm() = default;
-
+ 
 -  class iterator : public std::iterator<std::bidirectional_iterator_tag, uint32_t> {
 +  class iterator {
     public:
@@ -16,16 +151,16 @@
 +    using reference = uint32_t&;
 +
      iterator(ElfInterfaceArm* interface, size_t index) : interface_(interface), index_(index) { }
-
+ 
      iterator& operator++() { index_++; return *this; }
 diff --git a/src/libunwindstack/include/unwindstack/DwarfSection.h b/src/libunwindstack/include/unwindstack/DwarfSection.h
-index af823da..7891adc 100644
+index 33435b2..c5f2015 100644
 --- a/src/libunwindstack/include/unwindstack/DwarfSection.h
 +++ b/src/libunwindstack/include/unwindstack/DwarfSection.h
 @@ -42,8 +42,14 @@ class DwarfSection {
    DwarfSection(Memory* memory);
    virtual ~DwarfSection() = default;
-
+ 
 -  class iterator : public std::iterator<std::bidirectional_iterator_tag, DwarfFde*> {
 +  class iterator {
     public:
diff --git a/patches/0006-include-algorithm-header.patch b/patches/0006-include-algorithm-header.patch
index d7a34e2..e657a0c 100644
--- a/patches/0006-include-algorithm-header.patch
+++ b/patches/0006-include-algorithm-header.patch
@@ -1,3 +1,28 @@
+diff --git a/src/libdexfile/dex/descriptors_names.cc b/src/libdexfile/dex/descriptors_names.cc
+index 44cb7cb..a5378dc 100644
+--- a/src/libdexfile/dex/descriptors_names.cc
++++ b/src/libdexfile/dex/descriptors_names.cc
+@@ -16,6 +16,8 @@
+ 
+ #include "descriptors_names.h"
+ 
++#include <algorithm>
++
+ #include "android-base/stringprintf.h"
+ #include "android-base/strings.h"
+ 
+diff --git a/src/libdexfile/external/dex_file_ext.cc b/src/libdexfile/external/dex_file_ext.cc
+index 7c0bf2d..bd0b9e6 100644
+--- a/src/libdexfile/external/dex_file_ext.cc
++++ b/src/libdexfile/external/dex_file_ext.cc
+@@ -22,6 +22,7 @@
+ #include <sys/types.h>
+ #include <unistd.h>
+ 
++#include <algorithm>
+ #include <cerrno>
+ #include <cstring>
+ #include <deque>
 diff --git a/src/libunwindstack/DwarfSection.cpp b/src/libunwindstack/DwarfSection.cpp
 index 34d37b0..7174866 100644
 --- a/src/libunwindstack/DwarfSection.cpp
diff --git a/patches/0009-disable-thread-annotations.patch b/patches/0009-disable-thread-annotations.patch
new file mode 100644
index 0000000..8d499f9
--- /dev/null
+++ b/patches/0009-disable-thread-annotations.patch
@@ -0,0 +1,38 @@
+diff --git a/src/android-base/include/android-base/thread_annotations.h b/src/android-base/include/android-base/thread_annotations.h
+index 53fe6da..95d3c7c 100644
+--- a/src/android-base/include/android-base/thread_annotations.h
++++ b/src/android-base/include/android-base/thread_annotations.h
+@@ -47,20 +47,17 @@
+ #define ACQUIRED_AFTER(...) \
+       THREAD_ANNOTATION_ATTRIBUTE__(acquired_after(__VA_ARGS__))
+ 
+-#define REQUIRES(...) \
+-      THREAD_ANNOTATION_ATTRIBUTE__(requires_capability(__VA_ARGS__))
++#define REQUIRES(...)
+ 
+ #define REQUIRES_SHARED(...) \
+       THREAD_ANNOTATION_ATTRIBUTE__(requires_shared_capability(__VA_ARGS__))
+ 
+-#define ACQUIRE(...) \
+-      THREAD_ANNOTATION_ATTRIBUTE__(acquire_capability(__VA_ARGS__))
++#define ACQUIRE(...)
+ 
+ #define ACQUIRE_SHARED(...) \
+       THREAD_ANNOTATION_ATTRIBUTE__(acquire_shared_capability(__VA_ARGS__))
+ 
+-#define RELEASE(...) \
+-      THREAD_ANNOTATION_ATTRIBUTE__(release_capability(__VA_ARGS__))
++#define RELEASE(...)
+ 
+ #define RELEASE_SHARED(...) \
+       THREAD_ANNOTATION_ATTRIBUTE__(release_shared_capability(__VA_ARGS__))
+@@ -80,8 +77,7 @@
+ #define ASSERT_SHARED_CAPABILITY(x) \
+       THREAD_ANNOTATION_ATTRIBUTE__(assert_shared_capability(x))
+ 
+-#define RETURN_CAPABILITY(x) \
+-      THREAD_ANNOTATION_ATTRIBUTE__(lock_returned(x))
++#define RETURN_CAPABILITY(x)
+ 
+ #define EXCLUSIVE_LOCK_FUNCTION(...) \
+       THREAD_ANNOTATION_ATTRIBUTE__(exclusive_lock_function(__VA_ARGS__))
diff --git a/patches/0010-replace-allocator-destroy-construct-calls.patch b/patches/0010-replace-allocator-destroy-construct-calls.patch
new file mode 100644
index 0000000..9ff21c6
--- /dev/null
+++ b/patches/0010-replace-allocator-destroy-construct-calls.patch
@@ -0,0 +1,31 @@
+diff --git a/src/libartbase/base/hash_set.h b/src/libartbase/base/hash_set.h
+index c4af1b6..d1acc6d 100644
+--- a/src/libartbase/base/hash_set.h
++++ b/src/libartbase/base/hash_set.h
+@@ -734,7 +734,7 @@ class HashSet {
+     data_ = allocfn_.allocate(num_buckets_);
+     owns_data_ = true;
+     for (size_t i = 0; i < num_buckets_; ++i) {
+-      allocfn_.construct(allocfn_.address(data_[i]));
++      std::allocator_traits<Alloc>::construct(allocfn_, std::addressof(data_[i]));
+       emptyfn_.MakeEmpty(data_[i]);
+     }
+   }
+@@ -742,7 +742,7 @@ class HashSet {
+   void DeallocateStorage() {
+     if (owns_data_) {
+       for (size_t i = 0; i < NumBuckets(); ++i) {
+-        allocfn_.destroy(allocfn_.address(data_[i]));
++        std::allocator_traits<Alloc>::destroy(allocfn_, std::addressof(data_[i]));
+       }
+       if (data_ != nullptr) {
+         allocfn_.deallocate(data_, NumBuckets());
+@@ -777,7 +777,7 @@ class HashSet {
+         data_[FirstAvailableSlot(IndexForHash(hashfn_(element)))] = std::move(element);
+       }
+       if (owned_data) {
+-        allocfn_.destroy(allocfn_.address(element));
++        std::allocator_traits<Alloc>::destroy(allocfn_, std::addressof(element));
+       }
+     }
+     if (owned_data) {
diff --git a/patches/0011-dont-compile-unused-functions.patch b/patches/0011-dont-compile-unused-functions.patch
new file mode 100644
index 0000000..bb49063
--- /dev/null
+++ b/patches/0011-dont-compile-unused-functions.patch
@@ -0,0 +1,211 @@
+diff --git a/patches/0011-dont-compile-unused-functions.patch b/patches/0011-dont-compile-unused-functions.patch
+index bed8b8d..e69de29 100644
+--- a/patches/0011-dont-compile-unused-functions.patch
++++ b/patches/0011-dont-compile-unused-functions.patch
+@@ -1,98 +0,0 @@
+-diff --git a/src/libdexfile/dex/dex_file_layout.cc b/src/libdexfile/dex/dex_file_layout.cc
+-index f15e925..fe5e202 100644
+---- a/src/libdexfile/dex/dex_file_layout.cc
+-+++ b/src/libdexfile/dex/dex_file_layout.cc
+-@@ -73,6 +73,7 @@ void DexLayoutSections::MadviseAtLoad(const DexFile* dex_file) const {
+- #endif
+- }
+- 
+-+#if 0
+- std::ostream& operator<<(std::ostream& os, const DexLayoutSection& section) {
+-   for (size_t i = 0; i < static_cast<size_t>(LayoutType::kLayoutTypeCount); ++i) {
+-     const DexLayoutSection::Subsection& part = section.parts_[i];
+-@@ -88,5 +89,6 @@ std::ostream& operator<<(std::ostream& os, const DexLayoutSections& sections) {
+-   }
+-   return os;
+- }
+-+#endif
+- 
+- }  // namespace art
+-diff --git a/src/libdexfile/dex/dex_file_loader.cc b/src/libdexfile/dex/dex_file_loader.cc
+-index 861f911..d2fe6c1 100644
+---- a/src/libdexfile/dex/dex_file_loader.cc
+-+++ b/src/libdexfile/dex/dex_file_loader.cc
+-@@ -59,6 +59,8 @@ class VectorContainer : public DexFileContainer {
+- 
+- using android::base::StringPrintf;
+- 
+-+#if 0
+-+
+- class DexZipArchive;
+- 
+- class DexZipEntry {
+-@@ -148,6 +150,7 @@ static bool IsZipMagic(uint32_t magic) {
+-   return (('P' == ((magic >> 0) & 0xff)) &&
+-           ('K' == ((magic >> 8) & 0xff)));
+- }
+-+#endif
+- 
+- bool DexFileLoader::IsMagicValid(uint32_t magic) {
+-   return IsMagicValid(reinterpret_cast<uint8_t*>(&magic));
+-@@ -292,6 +295,7 @@ std::unique_ptr<const DexFile> DexFileLoader::OpenWithDataSection(
+-                     /*verify_result=*/ nullptr);
+- }
+- 
+-+#if 0
+- bool DexFileLoader::OpenAll(
+-     const uint8_t* base,
+-     size_t size,
+-@@ -337,6 +341,7 @@ bool DexFileLoader::OpenAll(
+-   *error_msg = StringPrintf("Expected valid zip or dex file");
+-   return false;
+- }
+-+#endif
+- 
+- std::unique_ptr<DexFile> DexFileLoader::OpenCommon(const uint8_t* base,
+-                                                    size_t size,
+-@@ -412,6 +417,7 @@ std::unique_ptr<DexFile> DexFileLoader::OpenCommon(const uint8_t* base,
+-   return dex_file;
+- }
+- 
+-+#if 0
+- std::unique_ptr<const DexFile> DexFileLoader::OpenOneDexFileFromZip(
+-     const DexZipArchive& zip_archive,
+-     const char* entry_name,
+-@@ -473,6 +479,7 @@ std::unique_ptr<const DexFile> DexFileLoader::OpenOneDexFileFromZip(
+- // seems an excessive number.
+- static constexpr size_t kWarnOnManyDexFilesThreshold = 100;
+- 
+-+
+- bool DexFileLoader::OpenAllDexFilesFromZip(
+-     const DexZipArchive& zip_archive,
+-     const std::string& location,
+-@@ -534,4 +541,5 @@ bool DexFileLoader::OpenAllDexFilesFromZip(
+-     return true;
+-   }
+- }
+-+#endif
+- }  // namespace art
+-diff --git a/src/libdexfile/dex/dex_file_loader.h b/src/libdexfile/dex/dex_file_loader.h
+-index d6268bc..e6adf9c 100644
+---- a/src/libdexfile/dex/dex_file_loader.h
+-+++ b/src/libdexfile/dex/dex_file_loader.h
+-@@ -161,6 +161,7 @@ class DexFileLoader {
+-       std::string* error_msg) const;
+- 
+- 
+-+#if 0
+-   // Opens all .dex files found in the memory map, guessing the container format based on file
+-   // extension.
+-   virtual bool OpenAll(const uint8_t* base,
+-@@ -171,6 +172,7 @@ class DexFileLoader {
+-                        DexFileLoaderErrorCode* error_code,
+-                        std::string* error_msg,
+-                        std::vector<std::unique_ptr<const DexFile>>* dex_files) const;
+-+#endif
+- 
+-  protected:
+-   enum class VerifyResult {  // private
+diff --git a/src/libdexfile/dex/dex_file_layout.cc b/src/libdexfile/dex/dex_file_layout.cc
+index f15e925..fe5e202 100644
+--- a/src/libdexfile/dex/dex_file_layout.cc
++++ b/src/libdexfile/dex/dex_file_layout.cc
+@@ -73,6 +73,7 @@ void DexLayoutSections::MadviseAtLoad(const DexFile* dex_file) const {
+ #endif
+ }
+ 
++#if 0
+ std::ostream& operator<<(std::ostream& os, const DexLayoutSection& section) {
+   for (size_t i = 0; i < static_cast<size_t>(LayoutType::kLayoutTypeCount); ++i) {
+     const DexLayoutSection::Subsection& part = section.parts_[i];
+@@ -88,5 +89,6 @@ std::ostream& operator<<(std::ostream& os, const DexLayoutSections& sections) {
+   }
+   return os;
+ }
++#endif
+ 
+ }  // namespace art
+diff --git a/src/libdexfile/dex/dex_file_loader.cc b/src/libdexfile/dex/dex_file_loader.cc
+index 861f911..3071537 100644
+--- a/src/libdexfile/dex/dex_file_loader.cc
++++ b/src/libdexfile/dex/dex_file_loader.cc
+@@ -23,7 +23,9 @@
+ #include "dex_file.h"
+ #include "dex_file_verifier.h"
+ #include "standard_dex_file.h"
++#if 0
+ #include "ziparchive/zip_archive.h"
++#endif
+ 
+ namespace art {
+ 
+@@ -59,6 +61,8 @@ class VectorContainer : public DexFileContainer {
+ 
+ using android::base::StringPrintf;
+ 
++#if 0
++
+ class DexZipArchive;
+ 
+ class DexZipEntry {
+@@ -148,6 +152,7 @@ static bool IsZipMagic(uint32_t magic) {
+   return (('P' == ((magic >> 0) & 0xff)) &&
+           ('K' == ((magic >> 8) & 0xff)));
+ }
++#endif
+ 
+ bool DexFileLoader::IsMagicValid(uint32_t magic) {
+   return IsMagicValid(reinterpret_cast<uint8_t*>(&magic));
+@@ -292,6 +297,7 @@ std::unique_ptr<const DexFile> DexFileLoader::OpenWithDataSection(
+                     /*verify_result=*/ nullptr);
+ }
+ 
++#if 0
+ bool DexFileLoader::OpenAll(
+     const uint8_t* base,
+     size_t size,
+@@ -337,6 +343,7 @@ bool DexFileLoader::OpenAll(
+   *error_msg = StringPrintf("Expected valid zip or dex file");
+   return false;
+ }
++#endif
+ 
+ std::unique_ptr<DexFile> DexFileLoader::OpenCommon(const uint8_t* base,
+                                                    size_t size,
+@@ -412,6 +419,7 @@ std::unique_ptr<DexFile> DexFileLoader::OpenCommon(const uint8_t* base,
+   return dex_file;
+ }
+ 
++#if 0
+ std::unique_ptr<const DexFile> DexFileLoader::OpenOneDexFileFromZip(
+     const DexZipArchive& zip_archive,
+     const char* entry_name,
+@@ -473,6 +481,7 @@ std::unique_ptr<const DexFile> DexFileLoader::OpenOneDexFileFromZip(
+ // seems an excessive number.
+ static constexpr size_t kWarnOnManyDexFilesThreshold = 100;
+ 
++
+ bool DexFileLoader::OpenAllDexFilesFromZip(
+     const DexZipArchive& zip_archive,
+     const std::string& location,
+@@ -534,4 +543,5 @@ bool DexFileLoader::OpenAllDexFilesFromZip(
+     return true;
+   }
+ }
++#endif
+ }  // namespace art
+diff --git a/src/libdexfile/dex/dex_file_loader.h b/src/libdexfile/dex/dex_file_loader.h
+index d6268bc..e6adf9c 100644
+--- a/src/libdexfile/dex/dex_file_loader.h
++++ b/src/libdexfile/dex/dex_file_loader.h
+@@ -161,6 +161,7 @@ class DexFileLoader {
+       std::string* error_msg) const;
+ 
+ 
++#if 0
+   // Opens all .dex files found in the memory map, guessing the container format based on file
+   // extension.
+   virtual bool OpenAll(const uint8_t* base,
+@@ -171,6 +172,7 @@ class DexFileLoader {
+                        DexFileLoaderErrorCode* error_code,
+                        std::string* error_msg,
+                        std::vector<std::unique_ptr<const DexFile>>* dex_files) const;
++#endif
+ 
+  protected:
+   enum class VerifyResult {  // private
diff --git a/src/android-base/include/android-base/logging.h b/src/android-base/include/android-base/logging.h
index 179ddf0..2d21638 100644
--- a/src/android-base/include/android-base/logging.h
+++ b/src/android-base/include/android-base/logging.h
@@ -218,7 +218,13 @@
 // FATAL it also causes an abort. For example:
 //
 //     LOG(FATAL) << "We didn't expect to reach here";
-#define LOG(severity) LOGGING_PREAMBLE(severity) && LOG_STREAM(severity)
+class FakeLog {
+ public:
+  template<typename T>
+  FakeLog operator<<(const T&) { return *this; }
+  operator bool() { return false; }
+};
+#define LOG(severity) false && ::android::base::FakeLog()
 
 // Checks if we want to log something, and sets up appropriate RAII objects if
 // so.
@@ -230,11 +236,7 @@
 
 // A variant of LOG that also logs the current errno value. To be used when
 // library calls fail.
-#define PLOG(severity)                                                           \
-  LOGGING_PREAMBLE(severity) &&                                                  \
-      ::android::base::LogMessage(__FILE__, __LINE__, SEVERITY_LAMBDA(severity), \
-                                  _LOG_TAG_INTERNAL, errno)                      \
-          .stream()
+#define PLOG(severity) false && ::android::base::FakeLog()
 
 // Marker that code is yet to be implemented.
 #define UNIMPLEMENTED(level) \
@@ -248,9 +250,7 @@
 //       "Check failed: false == true".
 #define CHECK(x)                                                                                 \
   LIKELY((x)) || ABORT_AFTER_LOG_FATAL_EXPR(false) ||                                            \
-      ::android::base::LogMessage(__FILE__, __LINE__, ::android::base::FATAL, _LOG_TAG_INTERNAL, \
-                                  -1)                                                            \
-              .stream()                                                                          \
+      ::android::base::FakeLog()                                                                 \
           << "Check failed: " #x << " "
 
 // clang-format off
@@ -260,8 +260,7 @@
        UNLIKELY(!(_values.lhs.v OP _values.rhs.v));                                              \
        /* empty */)                                                                              \
   ABORT_AFTER_LOG_FATAL                                                                          \
-  ::android::base::LogMessage(__FILE__, __LINE__, ::android::base::FATAL, _LOG_TAG_INTERNAL, -1) \
-          .stream()                                                                              \
+  ::android::base::FakeLog()                                                                     \
       << "Check failed: " << #LHS << " " << #OP << " " << #RHS << " (" #LHS "="                  \
       << ::android::base::LogNullGuard<decltype(_values.lhs.v)>::Guard(_values.lhs.v)            \
       << ", " #RHS "="                                                                           \
diff --git a/src/android-base/include/android-base/thread_annotations.h b/src/android-base/include/android-base/thread_annotations.h
index 53fe6da..95d3c7c 100644
--- a/src/android-base/include/android-base/thread_annotations.h
+++ b/src/android-base/include/android-base/thread_annotations.h
@@ -47,20 +47,17 @@
 #define ACQUIRED_AFTER(...) \
       THREAD_ANNOTATION_ATTRIBUTE__(acquired_after(__VA_ARGS__))
 
-#define REQUIRES(...) \
-      THREAD_ANNOTATION_ATTRIBUTE__(requires_capability(__VA_ARGS__))
+#define REQUIRES(...)
 
 #define REQUIRES_SHARED(...) \
       THREAD_ANNOTATION_ATTRIBUTE__(requires_shared_capability(__VA_ARGS__))
 
-#define ACQUIRE(...) \
-      THREAD_ANNOTATION_ATTRIBUTE__(acquire_capability(__VA_ARGS__))
+#define ACQUIRE(...)
 
 #define ACQUIRE_SHARED(...) \
       THREAD_ANNOTATION_ATTRIBUTE__(acquire_shared_capability(__VA_ARGS__))
 
-#define RELEASE(...) \
-      THREAD_ANNOTATION_ATTRIBUTE__(release_capability(__VA_ARGS__))
+#define RELEASE(...)
 
 #define RELEASE_SHARED(...) \
       THREAD_ANNOTATION_ATTRIBUTE__(release_shared_capability(__VA_ARGS__))
@@ -80,8 +77,7 @@
 #define ASSERT_SHARED_CAPABILITY(x) \
       THREAD_ANNOTATION_ATTRIBUTE__(assert_shared_capability(x))
 
-#define RETURN_CAPABILITY(x) \
-      THREAD_ANNOTATION_ATTRIBUTE__(lock_returned(x))
+#define RETURN_CAPABILITY(x)
 
 #define EXCLUSIVE_LOCK_FUNCTION(...) \
       THREAD_ANNOTATION_ATTRIBUTE__(exclusive_lock_function(__VA_ARGS__))
diff --git a/src/android-base/include/android-base/unique_fd.h b/src/android-base/include/android-base/unique_fd.h
index 1ffe02f..110712c 100644
--- a/src/android-base/include/android-base/unique_fd.h
+++ b/src/android-base/include/android-base/unique_fd.h
@@ -29,7 +29,11 @@
 // Including other headers from libbase frequently results in inclusion of
 // android-base/macros.h, which causes macro collisions.
 
-#if defined(__BIONIC__)
+#if defined(__BIONIC__) && defined(__ANDROID_API__) && __ANDROID_API__ >= 29
+  #define FDSAN_AVAILABLE 1
+#endif
+
+#if defined(FDSAN_AVAILABLE)
 #include <android/fdsan.h>
 #endif
 #if !defined(_WIN32) && !defined(__TRUSTY__)
@@ -151,7 +155,7 @@
 // The actual details of closing are factored out to support unusual cases.
 // Almost everyone will want this DefaultCloser, which handles fdsan on bionic.
 struct DefaultCloser {
-#if defined(__BIONIC__)
+#if defined(FDSAN_AVAILABLE)
   static void Tag(int fd, void* old_addr, void* new_addr) {
     if (android_fdsan_exchange_owner_tag) {
       uint64_t old_tag = android_fdsan_create_owner_tag(ANDROID_FDSAN_OWNER_TYPE_UNIQUE_FD,
diff --git a/src/libartbase/base/hash_set.h b/src/libartbase/base/hash_set.h
index c4af1b6..d1acc6d 100644
--- a/src/libartbase/base/hash_set.h
+++ b/src/libartbase/base/hash_set.h
@@ -734,7 +734,7 @@
     data_ = allocfn_.allocate(num_buckets_);
     owns_data_ = true;
     for (size_t i = 0; i < num_buckets_; ++i) {
-      allocfn_.construct(allocfn_.address(data_[i]));
+      std::allocator_traits<Alloc>::construct(allocfn_, std::addressof(data_[i]));
       emptyfn_.MakeEmpty(data_[i]);
     }
   }
@@ -742,7 +742,7 @@
   void DeallocateStorage() {
     if (owns_data_) {
       for (size_t i = 0; i < NumBuckets(); ++i) {
-        allocfn_.destroy(allocfn_.address(data_[i]));
+        std::allocator_traits<Alloc>::destroy(allocfn_, std::addressof(data_[i]));
       }
       if (data_ != nullptr) {
         allocfn_.deallocate(data_, NumBuckets());
@@ -777,7 +777,7 @@
         data_[FirstAvailableSlot(IndexForHash(hashfn_(element)))] = std::move(element);
       }
       if (owned_data) {
-        allocfn_.destroy(allocfn_.address(element));
+        std::allocator_traits<Alloc>::destroy(allocfn_, std::addressof(element));
       }
     }
     if (owned_data) {
diff --git a/src/libartbase/base/stl_util.h b/src/libartbase/base/stl_util.h
index 0ae4fd2..d16b01e 100644
--- a/src/libartbase/base/stl_util.h
+++ b/src/libartbase/base/stl_util.h
@@ -156,10 +156,14 @@
 }
 
 template <typename IterLeft, typename IterRight>
-class ZipLeftIter : public std::iterator<
-                        std::forward_iterator_tag,
-                        std::pair<typename IterLeft::value_type, typename IterRight::value_type>> {
+class ZipLeftIter {
  public:
+  using iterator_category = std::forward_iterator_tag;
+  using value_type = std::pair<typename IterLeft::value_type, typename IterRight::value_type>;
+  using difference_type = std::ptrdiff_t;
+  using pointer = std::pair<typename IterLeft::value_type, typename IterRight::value_type>*;
+  using reference = std::pair<typename IterLeft::value_type, typename IterRight::value_type>&;
+
   ZipLeftIter(IterLeft left, IterRight right) : left_iter_(left), right_iter_(right) {}
   ZipLeftIter<IterLeft, IterRight>& operator++() {
     ++left_iter_;
@@ -186,8 +190,13 @@
   IterRight right_iter_;
 };
 
-class CountIter : public std::iterator<std::forward_iterator_tag, size_t, size_t, size_t, size_t> {
+class CountIter {
  public:
+  using iterator_category = std::forward_iterator_tag;
+  using value_type = size_t;
+  using difference_type = size_t;
+  using pointer = size_t;
+  using reference = size_t;
   CountIter() : count_(0) {}
   explicit CountIter(size_t count) : count_(count) {}
   CountIter& operator++() {
@@ -238,9 +247,14 @@
 }
 
 template <typename RealIter, typename Filter>
-struct FilterIterator
-    : public std::iterator<std::forward_iterator_tag, typename RealIter::value_type> {
+struct FilterIterator {
  public:
+  using iterator_category = std::forward_iterator_tag;
+  using value_type = typename RealIter::value_type;
+  using difference_type = std::ptrdiff_t;
+  using pointer = typename RealIter::value_type*;
+  using reference = typename RealIter::value_type&;
+
   FilterIterator(RealIter rl,
                  Filter cond,
                  std::optional<RealIter> end = std::nullopt)
@@ -324,8 +338,14 @@
 }
 
 // Helper struct for iterating a split-string without allocation.
-struct SplitStringIter : public std::iterator<std::forward_iterator_tag, std::string_view> {
+struct SplitStringIter {
  public:
+  using iterator_category = std::forward_iterator_tag;
+  using value_type = std::string_view;
+  using difference_type = std::ptrdiff_t;
+  using pointer = std::string_view*;
+  using reference = std::string_view&;
+
   // Direct iterator constructor. The iteration state is only the current index.
   // We use that with the split char and the full string to get the current and
   // next segment.
diff --git a/src/libdexfile/dex/class_accessor.h b/src/libdexfile/dex/class_accessor.h
index a3ee2bd..7f7cdf6 100644
--- a/src/libdexfile/dex/class_accessor.h
+++ b/src/libdexfile/dex/class_accessor.h
@@ -177,11 +177,13 @@
   };
 
   template <typename DataType>
-  class DataIterator : public std::iterator<std::forward_iterator_tag, DataType> {
+  class DataIterator {
    public:
-    using value_type = typename std::iterator<std::forward_iterator_tag, DataType>::value_type;
-    using difference_type =
-        typename std::iterator<std::forward_iterator_tag, value_type>::difference_type;
+    using iterator_category = std::forward_iterator_tag;
+    using value_type = DataType;
+    using difference_type = std::ptrdiff_t;
+    using pointer = DataType*;
+    using reference = DataType&;
 
     DataIterator(const DexFile& dex_file,
                  uint32_t position,
diff --git a/src/libdexfile/dex/class_iterator.h b/src/libdexfile/dex/class_iterator.h
index 8ed585b..9ace41b 100644
--- a/src/libdexfile/dex/class_iterator.h
+++ b/src/libdexfile/dex/class_iterator.h
@@ -41,10 +41,13 @@
 };
 
 // Iterator for visiting classes in a Dex file.
-class ClassIterator : public std::iterator<std::forward_iterator_tag, ClassIteratorData> {
+class ClassIterator {
  public:
-  using value_type = std::iterator<std::forward_iterator_tag, ClassIteratorData>::value_type;
-  using difference_type = std::iterator<std::forward_iterator_tag, value_type>::difference_type;
+  using iterator_category = std::forward_iterator_tag;
+  using value_type = ClassIteratorData;
+  using difference_type = std::ptrdiff_t;
+  using pointer = ClassIteratorData*;
+  using reference = ClassIteratorData&;
 
   ClassIterator(const DexFile& dex_file, uint32_t class_def_idx)
       : data_(dex_file, class_def_idx) {}
diff --git a/src/libdexfile/dex/descriptors_names.cc b/src/libdexfile/dex/descriptors_names.cc
index 44cb7cb..a5378dc 100644
--- a/src/libdexfile/dex/descriptors_names.cc
+++ b/src/libdexfile/dex/descriptors_names.cc
@@ -16,6 +16,8 @@
 
 #include "descriptors_names.h"
 
+#include <algorithm>
+
 #include "android-base/stringprintf.h"
 #include "android-base/strings.h"
 
diff --git a/src/libdexfile/dex/dex_file_layout.cc b/src/libdexfile/dex/dex_file_layout.cc
index f15e925..fe5e202 100644
--- a/src/libdexfile/dex/dex_file_layout.cc
+++ b/src/libdexfile/dex/dex_file_layout.cc
@@ -73,6 +73,7 @@
 #endif
 }
 
+#if 0
 std::ostream& operator<<(std::ostream& os, const DexLayoutSection& section) {
   for (size_t i = 0; i < static_cast<size_t>(LayoutType::kLayoutTypeCount); ++i) {
     const DexLayoutSection::Subsection& part = section.parts_[i];
@@ -88,5 +89,6 @@
   }
   return os;
 }
+#endif
 
 }  // namespace art
diff --git a/src/libdexfile/dex/dex_file_loader.cc b/src/libdexfile/dex/dex_file_loader.cc
index 861f911..3071537 100644
--- a/src/libdexfile/dex/dex_file_loader.cc
+++ b/src/libdexfile/dex/dex_file_loader.cc
@@ -23,7 +23,9 @@
 #include "dex_file.h"
 #include "dex_file_verifier.h"
 #include "standard_dex_file.h"
+#if 0
 #include "ziparchive/zip_archive.h"
+#endif
 
 namespace art {
 
@@ -59,6 +61,8 @@
 
 using android::base::StringPrintf;
 
+#if 0
+
 class DexZipArchive;
 
 class DexZipEntry {
@@ -148,6 +152,7 @@
   return (('P' == ((magic >> 0) & 0xff)) &&
           ('K' == ((magic >> 8) & 0xff)));
 }
+#endif
 
 bool DexFileLoader::IsMagicValid(uint32_t magic) {
   return IsMagicValid(reinterpret_cast<uint8_t*>(&magic));
@@ -292,6 +297,7 @@
                     /*verify_result=*/ nullptr);
 }
 
+#if 0
 bool DexFileLoader::OpenAll(
     const uint8_t* base,
     size_t size,
@@ -337,6 +343,7 @@
   *error_msg = StringPrintf("Expected valid zip or dex file");
   return false;
 }
+#endif
 
 std::unique_ptr<DexFile> DexFileLoader::OpenCommon(const uint8_t* base,
                                                    size_t size,
@@ -412,6 +419,7 @@
   return dex_file;
 }
 
+#if 0
 std::unique_ptr<const DexFile> DexFileLoader::OpenOneDexFileFromZip(
     const DexZipArchive& zip_archive,
     const char* entry_name,
@@ -473,6 +481,7 @@
 // seems an excessive number.
 static constexpr size_t kWarnOnManyDexFilesThreshold = 100;
 
+
 bool DexFileLoader::OpenAllDexFilesFromZip(
     const DexZipArchive& zip_archive,
     const std::string& location,
@@ -534,4 +543,5 @@
     return true;
   }
 }
+#endif
 }  // namespace art
diff --git a/src/libdexfile/dex/dex_file_loader.h b/src/libdexfile/dex/dex_file_loader.h
index d6268bc..e6adf9c 100644
--- a/src/libdexfile/dex/dex_file_loader.h
+++ b/src/libdexfile/dex/dex_file_loader.h
@@ -161,6 +161,7 @@
       std::string* error_msg) const;
 
 
+#if 0
   // Opens all .dex files found in the memory map, guessing the container format based on file
   // extension.
   virtual bool OpenAll(const uint8_t* base,
@@ -171,6 +172,7 @@
                        DexFileLoaderErrorCode* error_code,
                        std::string* error_msg,
                        std::vector<std::unique_ptr<const DexFile>>* dex_files) const;
+#endif
 
  protected:
   enum class VerifyResult {  // private
diff --git a/src/libdexfile/dex/dex_instruction_iterator.h b/src/libdexfile/dex/dex_instruction_iterator.h
index 6c7f42a..0ce6c96 100644
--- a/src/libdexfile/dex/dex_instruction_iterator.h
+++ b/src/libdexfile/dex/dex_instruction_iterator.h
@@ -57,11 +57,13 @@
 };
 
 // Base helper class to prevent duplicated comparators.
-class DexInstructionIteratorBase : public
-        std::iterator<std::forward_iterator_tag, DexInstructionPcPair> {
+class DexInstructionIteratorBase {
  public:
-  using value_type = std::iterator<std::forward_iterator_tag, DexInstructionPcPair>::value_type;
-  using difference_type = std::iterator<std::forward_iterator_tag, value_type>::difference_type;
+  using iterator_category = std::forward_iterator_tag;
+  using value_type = DexInstructionPcPair;
+  using difference_type = std::ptrdiff_t;
+  using pointer = DexInstructionPcPair*;
+  using reference = DexInstructionPcPair&;
 
   explicit DexInstructionIteratorBase(const Instruction* inst, uint32_t dex_pc)
       : data_(reinterpret_cast<const uint16_t*>(inst), dex_pc) {}
diff --git a/src/libdexfile/external/dex_file_ext.cc b/src/libdexfile/external/dex_file_ext.cc
index 7c0bf2d..bd0b9e6 100644
--- a/src/libdexfile/external/dex_file_ext.cc
+++ b/src/libdexfile/external/dex_file_ext.cc
@@ -22,6 +22,7 @@
 #include <sys/types.h>
 #include <unistd.h>
 
+#include <algorithm>
 #include <cerrno>
 #include <cstring>
 #include <deque>
diff --git a/src/libunwindstack/DwarfSection.cpp b/src/libunwindstack/DwarfSection.cpp
index 34d37b0..7174866 100644
--- a/src/libunwindstack/DwarfSection.cpp
+++ b/src/libunwindstack/DwarfSection.cpp
@@ -16,6 +16,8 @@
 
 #include <stdint.h>
 
+#include <algorithm>
+
 #include <unwindstack/DwarfError.h>
 #include <unwindstack/DwarfLocation.h>
 #include <unwindstack/DwarfMemory.h>
diff --git a/src/libunwindstack/ElfInterfaceArm.h b/src/libunwindstack/ElfInterfaceArm.h
index 6ee6dc9..a2435f2 100644
--- a/src/libunwindstack/ElfInterfaceArm.h
+++ b/src/libunwindstack/ElfInterfaceArm.h
@@ -32,8 +32,14 @@
   ElfInterfaceArm(Memory* memory) : ElfInterface32(memory) {}
   virtual ~ElfInterfaceArm() = default;
 
-  class iterator : public std::iterator<std::bidirectional_iterator_tag, uint32_t> {
+  class iterator {
    public:
+    using iterator_category = std::bidirectional_iterator_tag;
+    using value_type = uint32_t;
+    using difference_type = std::ptrdiff_t;
+    using pointer = uint32_t*;
+    using reference = uint32_t&;
+
     iterator(ElfInterfaceArm* interface, size_t index) : interface_(interface), index_(index) { }
 
     iterator& operator++() { index_++; return *this; }
diff --git a/src/libunwindstack/LogAndroid.cpp b/src/libunwindstack/LogAndroid.cpp
index a2bfc39..248cf2b 100644
--- a/src/libunwindstack/LogAndroid.cpp
+++ b/src/libunwindstack/LogAndroid.cpp
@@ -21,9 +21,11 @@
 #include <string>
 
 #define LOG_TAG "unwind"
+#if 0
 #include <log/log.h>
+#endif
 
-#if defined(__BIONIC__)
+#if defined(__BIONIC__) && !defined(__ANDROID_NDK__)
 #include <async_safe/log.h>
 #endif
 #include <android-base/stringprintf.h>
@@ -34,6 +36,7 @@
 
 namespace Log {
 
+#if 0
 // Send the data to the log.
 static void LogWithPriority(int priority, uint8_t indent, const char* format, va_list args) {
   std::string real_format;
@@ -44,29 +47,36 @@
   }
   LOG_PRI_VA(priority, LOG_TAG, real_format.c_str(), args);
 }
+#endif
 
 void Info(const char* format, ...) {
+#if 0
   va_list args;
   va_start(args, format);
   LogWithPriority(ANDROID_LOG_INFO, 0, format, args);
   va_end(args);
+#endif
 }
 
 void Info(uint8_t indent, const char* format, ...) {
+#if 0
   va_list args;
   va_start(args, format);
   LogWithPriority(ANDROID_LOG_INFO, indent, format, args);
   va_end(args);
+#endif
 }
 
 void Error(const char* format, ...) {
+#if 0
   va_list args;
   va_start(args, format);
   LogWithPriority(ANDROID_LOG_ERROR, 0, format, args);
   va_end(args);
+#endif
 }
 
-#if defined(__BIONIC__)
+#if defined(__BIONIC__) && !defined(__ANDROID_NDK__)
 void AsyncSafe(const char* format, ...) {
   va_list args;
   va_start(args, format);
diff --git a/src/libunwindstack/Memory.cpp b/src/libunwindstack/Memory.cpp
index 5cfe2f0..f5f37ee 100644
--- a/src/libunwindstack/Memory.cpp
+++ b/src/libunwindstack/Memory.cpp
@@ -201,6 +201,10 @@
   return nullptr;
 }
 
+std::unique_ptr<Memory> Memory::CreateLocalProcessMemory() {
+  return std::unique_ptr<Memory>(new MemoryLocal());
+}
+
 std::shared_ptr<Memory> Memory::CreateProcessMemory(pid_t pid) {
   if (pid == getpid()) {
     return std::shared_ptr<Memory>(new MemoryLocal());
diff --git a/src/libunwindstack/MemoryMte.cpp b/src/libunwindstack/MemoryMte.cpp
index 3841744..681aea6 100644
--- a/src/libunwindstack/MemoryMte.cpp
+++ b/src/libunwindstack/MemoryMte.cpp
@@ -17,7 +17,7 @@
 #include <sys/ptrace.h>
 #include <sys/uio.h>
 
-#if defined(__BIONIC__)
+#if defined(__BIONIC__) && !defined(__ANDROID_NDK__)
 #include <bionic/mte.h>
 #else
 #define mte_supported() false
diff --git a/src/libunwindstack/RegsArm64.cpp b/src/libunwindstack/RegsArm64.cpp
index 99eddb0..05a1809 100644
--- a/src/libunwindstack/RegsArm64.cpp
+++ b/src/libunwindstack/RegsArm64.cpp
@@ -19,7 +19,7 @@
 
 #include <functional>
 
-#if defined(__BIONIC__)
+#if defined(__BIONIC__) && !defined(__ANDROID_NDK__)
 #include <bionic/pac.h>
 #endif
 
@@ -60,7 +60,7 @@
   if (mask) {
     pc &= ~mask;
   } else {
-#if defined(__BIONIC__)
+#if defined(__BIONIC__) && !defined(__ANDROID_NDK__)
     pc = __bionic_clear_pac_bits(pc);
 #endif
   }
diff --git a/src/libunwindstack/include/unwindstack/DwarfSection.h b/src/libunwindstack/include/unwindstack/DwarfSection.h
index 33435b2..c5f2015 100644
--- a/src/libunwindstack/include/unwindstack/DwarfSection.h
+++ b/src/libunwindstack/include/unwindstack/DwarfSection.h
@@ -42,8 +42,14 @@
   DwarfSection(Memory* memory);
   virtual ~DwarfSection() = default;
 
-  class iterator : public std::iterator<std::bidirectional_iterator_tag, DwarfFde*> {
+  class iterator {
    public:
+    using iterator_category = std::bidirectional_iterator_tag;
+    using value_type = DwarfFde*;
+    using difference_type = std::ptrdiff_t;
+    using pointer = DwarfFde**;
+    using reference = DwarfFde*&;
+
     iterator(DwarfSection* section, size_t index) : index_(index) {
       section->GetFdes(&fdes_);
       if (index_ == static_cast<size_t>(-1)) {
diff --git a/src/libunwindstack/include/unwindstack/Memory.h b/src/libunwindstack/include/unwindstack/Memory.h
index d6ca29e..5ec9787 100644
--- a/src/libunwindstack/include/unwindstack/Memory.h
+++ b/src/libunwindstack/include/unwindstack/Memory.h
@@ -32,6 +32,7 @@
   Memory() = default;
   virtual ~Memory() = default;
 
+  static std::unique_ptr<Memory> CreateLocalProcessMemory();
   static std::shared_ptr<Memory> CreateProcessMemory(pid_t pid);
   static std::shared_ptr<Memory> CreateProcessMemoryCached(pid_t pid);
   static std::shared_ptr<Memory> CreateProcessMemoryThreadCached(pid_t pid);
diff --git a/src/libunwindstack/include/unwindstack/Unwinder.h b/src/libunwindstack/include/unwindstack/Unwinder.h
index d78da5c..91fd1d5 100644
--- a/src/libunwindstack/include/unwindstack/Unwinder.h
+++ b/src/libunwindstack/include/unwindstack/Unwinder.h
@@ -85,7 +85,7 @@
   static std::string FormatFrame(ArchEnum arch, const FrameData& frame,
                                  bool display_build_id = true);
 
-  void SetArch(ArchEnum arch) { arch_ = arch; };
+  void SetArch(ArchEnum arch) { arch_ = arch; }
 
   void SetJitDebug(JitDebug* jit_debug);