Merge "bootstat: Add more boot reasons found by logging in the wild."
diff --git a/base/Android.bp b/base/Android.bp
index 0fd00ea..f4a8411 100644
--- a/base/Android.bp
+++ b/base/Android.bp
@@ -64,16 +64,20 @@
     target: {
         android: {
             srcs: [
-                "errors_unix.cpp",
                 "properties.cpp",
-                "chrono_utils.cpp",
             ],
-            cppflags: ["-Wexit-time-destructors"],
             sanitize: {
                 misc_undefined: ["integer"],
             },
 
         },
+        linux: {
+            srcs: [
+                "chrono_utils.cpp",
+                "errors_unix.cpp",
+            ],
+            cppflags: ["-Wexit-time-destructors"],
+        },
         darwin: {
             srcs: [
                 "chrono_utils.cpp",
@@ -82,20 +86,8 @@
             cppflags: ["-Wexit-time-destructors"],
         },
         linux_bionic: {
-            srcs: [
-                "chrono_utils.cpp",
-                "errors_unix.cpp",
-            ],
-            cppflags: ["-Wexit-time-destructors"],
             enabled: true,
         },
-        linux_glibc: {
-            srcs: [
-                "chrono_utils.cpp",
-                "errors_unix.cpp",
-            ],
-            cppflags: ["-Wexit-time-destructors"],
-        },
         windows: {
             srcs: [
                 "errors_windows.cpp",
@@ -127,15 +119,12 @@
     ],
     target: {
         android: {
-            srcs: [
-                "chrono_utils_test.cpp",
-                "properties_test.cpp"
-            ],
+            srcs: ["properties_test.cpp"],
             sanitize: {
                 misc_undefined: ["integer"],
             },
         },
-        linux_glibc: {
+        linux: {
             srcs: ["chrono_utils_test.cpp"],
         },
         windows: {
diff --git a/bootstat/bootstat.cpp b/bootstat/bootstat.cpp
index 2095fb8..2270133 100644
--- a/bootstat/bootstat.cpp
+++ b/bootstat/bootstat.cpp
@@ -519,7 +519,6 @@
           android::base::ReadFdToString(fileno(fp), &content);
         }
         android_logcat_pclose(&ctx, fp);
-        android_logcat_destroy(&ctx);
         static const char logcat_battery[] = "W/healthd (    0): battery l=";
         const char* match = logcat_battery;
 
diff --git a/init/builtins.cpp b/init/builtins.cpp
index 027b392..20f1450 100644
--- a/init/builtins.cpp
+++ b/init/builtins.cpp
@@ -1014,7 +1014,7 @@
         {"verity_load_state",       {0,     0,    {false,  do_verity_load_state}}},
         {"verity_update_state",     {0,     0,    {false,  do_verity_update_state}}},
         {"wait",                    {1,     2,    {true,   do_wait}}},
-        {"wait_for_prop",           {2,     2,    {true,   do_wait_for_prop}}},
+        {"wait_for_prop",           {2,     2,    {false,  do_wait_for_prop}}},
         {"write",                   {2,     2,    {true,   do_write}}},
     };
     // clang-format on
diff --git a/init/subcontext.h b/init/subcontext.h
index ac77e08..e920034 100644
--- a/init/subcontext.h
+++ b/init/subcontext.h
@@ -35,7 +35,7 @@
 class Subcontext {
   public:
     Subcontext(std::string path_prefix, std::string context)
-        : path_prefix_(path_prefix), context_(std::move(context)) {
+        : path_prefix_(std::move(path_prefix)), context_(std::move(context)) {
         Fork();
     }
 
diff --git a/libbacktrace/Android.bp b/libbacktrace/Android.bp
index 2f20684..b2c0c0f 100644
--- a/libbacktrace/Android.bp
+++ b/libbacktrace/Android.bp
@@ -65,7 +65,7 @@
 
 cc_library {
     name: "libbacktrace",
-    vendor_available: true,
+    vendor_available: false,
     vndk: {
         enabled: true,
         support_system_process: true,
@@ -83,20 +83,7 @@
         darwin: {
             enabled: true,
         },
-        linux_glibc: {
-            srcs: libbacktrace_sources,
-
-            shared_libs: [
-                "libbase",
-                "liblog",
-                "libunwind",
-                "libunwindstack",
-            ],
-
-            static_libs: ["libcutils"],
-        },
-        linux_bionic: {
-            enabled: true,
+        linux: {
             srcs: libbacktrace_sources,
 
             shared_libs: [
@@ -109,16 +96,7 @@
             static_libs: ["libcutils"],
         },
         android: {
-            srcs: libbacktrace_sources,
-
-            shared_libs: [
-                "libbase",
-                "liblog",
-                "libunwind",
-                "libunwindstack",
-            ],
-
-            static_libs: ["libasync_safe", "libcutils"],
+            static_libs: ["libasync_safe"],
         },
     },
     whole_static_libs: ["libdemangle"],
@@ -135,13 +113,7 @@
     srcs: ["backtrace_testlib.cpp"],
 
     target: {
-        linux_glibc: {
-            shared_libs: [
-                "libunwind",
-                "libunwindstack",
-            ],
-        },
-        android: {
+        linux: {
             shared_libs: [
                 "libunwind",
                 "libunwindstack",
diff --git a/libunwindstack/Unwinder.cpp b/libunwindstack/Unwinder.cpp
index e648927..15a8893 100644
--- a/libunwindstack/Unwinder.cpp
+++ b/libunwindstack/Unwinder.cpp
@@ -52,7 +52,7 @@
   }
 
   frame->map_name = map_info->name;
-  frame->map_offset = map_info->elf_offset;
+  frame->map_offset = map_info->offset;
   frame->map_start = map_info->start;
   frame->map_end = map_info->end;
   frame->map_flags = map_info->flags;
diff --git a/libunwindstack/tests/UnwinderTest.cpp b/libunwindstack/tests/UnwinderTest.cpp
index 4d0366c..16640a1 100644
--- a/libunwindstack/tests/UnwinderTest.cpp
+++ b/libunwindstack/tests/UnwinderTest.cpp
@@ -95,6 +95,16 @@
     info.elf = elf;
     elf->FakeSetInterface(new ElfInterfaceFake(nullptr));
     maps_.FakeAddMapInfo(info);
+
+    info.name = "/fake/fake.apk";
+    info.start = 0x43000;
+    info.end = 0x44000;
+    info.offset = 0x1d000;
+    info.flags = PROT_READ | PROT_WRITE;
+    elf = new ElfFake(nullptr);
+    info.elf = elf;
+    elf->FakeSetInterface(new ElfInterfaceFake(nullptr));
+    maps_.FakeAddMapInfo(info);
   }
 
   void SetUp() override {
@@ -170,6 +180,33 @@
   EXPECT_EQ(PROT_READ | PROT_WRITE, frame->map_flags);
 }
 
+TEST_F(UnwinderTest, non_zero_map_offset) {
+  ElfInterfaceFake::FakePushFunctionData(FunctionData("Frame0", 0));
+
+  regs_.FakeSetPc(0x43000);
+  regs_.FakeSetSp(0x10000);
+  ElfInterfaceFake::FakePushStepData(StepData(0, 0, true));
+
+  Unwinder unwinder(64, &maps_, &regs_, process_memory_);
+  unwinder.Unwind();
+
+  ASSERT_EQ(1U, unwinder.NumFrames());
+
+  auto* frame = &unwinder.frames()[0];
+  EXPECT_EQ(0U, frame->num);
+  EXPECT_EQ(0U, frame->rel_pc);
+  EXPECT_EQ(0x43000U, frame->pc);
+  EXPECT_EQ(0x10000U, frame->sp);
+  EXPECT_EQ("Frame0", frame->function_name);
+  EXPECT_EQ(0U, frame->function_offset);
+  EXPECT_EQ("/fake/fake.apk", frame->map_name);
+  EXPECT_EQ(0x1d000U, frame->map_offset);
+  EXPECT_EQ(0x43000U, frame->map_start);
+  EXPECT_EQ(0x44000U, frame->map_end);
+  EXPECT_EQ(0U, frame->map_load_bias);
+  EXPECT_EQ(PROT_READ | PROT_WRITE, frame->map_flags);
+}
+
 // Verify that no attempt to continue after the step indicates it is done.
 TEST_F(UnwinderTest, no_frames_after_finished) {
   ElfInterfaceFake::FakePushFunctionData(FunctionData("Frame0", 0));
diff --git a/libutils/Android.bp b/libutils/Android.bp
index 30e6b49..3589e6f 100644
--- a/libutils/Android.bp
+++ b/libutils/Android.bp
@@ -93,8 +93,6 @@
     target: {
         android: {
             srcs: [
-                "Looper.cpp",
-                "ProcessCallStack.cpp",
                 "Trace.cpp",
             ],
 
@@ -112,6 +110,12 @@
                 misc_undefined: ["integer"],
             },
         },
+        linux: {
+            srcs: [
+                "Looper.cpp",
+                "ProcessCallStack.cpp",
+            ],
+        },
 
         host: {
             cflags: ["-DLIBUTILS_NATIVE=1"],
@@ -121,18 +125,8 @@
             },
         },
 
-        linux_glibc: {
-            srcs: [
-                "Looper.cpp",
-                "ProcessCallStack.cpp",
-            ],
-        },
         linux_bionic: {
             enabled: true,
-            srcs: [
-                "Looper.cpp",
-                "ProcessCallStack.cpp",
-            ],
         },
 
         darwin: {
diff --git a/libutils/tests/Android.bp b/libutils/tests/Android.bp
index 6911fc5..a891fca 100644
--- a/libutils/tests/Android.bp
+++ b/libutils/tests/Android.bp
@@ -34,8 +34,6 @@
     target: {
         android: {
             srcs: [
-                "Looper_test.cpp",
-                "RefBase_test.cpp",
                 "SystemClock_test.cpp",
             ],
             shared_libs: [
@@ -46,7 +44,7 @@
                 "libbase",
             ],
         },
-        linux_glibc: {
+        linux: {
             srcs: [
                 "Looper_test.cpp",
                 "RefBase_test.cpp",